Wolfgang Grandegger wrote:
>> static u16 spear1310_can_read_reg(const struct bosch_ccan_priv *priv,
>>                              enum ccan_regs reg)
>> {
>>      u16 val;
>>
>>      /* 16 bit registers are aligned at 16-bit boundary */
>>      val = readw(priv->reg_base + reg);
>>      return val;
>> }
>>
>> static void spear1310_can_write_reg(const struct bosch_ccan_priv *priv,
>>                              enum ccan_regs reg, u16 val)
>> {
>>      /* 16 bit registers are aligned at 16-bit boundary */
>>      writew(val, priv->reg_base + reg);
>> }
>>
>> The one for SPEAr320 will look like:
>> static u16 spear320_can_read_reg(const struct bosch_ccan_priv *priv,
>>                              enum ccan_regs reg)
>> {
>>      u16 val;
>>
>>      /* shifting 1 place because 16 bit registers are word aligned */
>>      val = readw(priv->reg_base + (reg << 1));
>>      return val;
>> }
>>
>> static void spear320_can_write_reg(const struct bosch_ccan_priv *priv,
>>                              enum ccan_regs reg, u16 val)
>> {
>>      /* shifting 1 place because 16 bit registers are word aligned */
>>      writew(val, priv->reg_base + (reg << 1));
>> }
> 
> These functions are still pretty generic and could be handled by a
> generic platform C_CAN driver via platform data field "reg_shift".

the sja1000 uses IORESOURCE_MEM_xxBIT for this. See [1].

cheers, Marc

[1]
http://lxr.linux.no/linux+v2.6.35/drivers/net/can/sja1000/sja1000_platform.c#L119
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to