Wolfgang Grandegger wrote:
> On 09/01/2010 02:37 PM, Marc Kleine-Budde wrote:
>> Wolfgang Grandegger wrote:
>>> On 09/01/2010 02:10 PM, Marc Kleine-Budde wrote:
>>>> 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
>>> Well, yes and no. I think for the SPEAr *word* accesses are required on
>>> a 2 and 4 byte boundary? Bhupesh? We could use IORESOURCE_MEM_16BIT and
>>> IORESOURCE_MEM_32BIT for these access types. But that might need to be
>>> extended. In the C_CAN manual there is written:
>>>
>>>  "Up to now the C_CAN module is delivered with three different
>>>   interfaces. An 8-bit interface for the Motorola HC08 controller and
>>>   two 16-bit interfaces to the AMBA APB bus from ARM. They can easily
>>>   be replaced by a user-defined module interface."
>> We can do a regshift of 1 and a full 32 bit access even with
>> IORESOURCE_MEM_16BIT, at least for now. Does 16 bit access work, too?
> 
> I don't understand!? So far I have only seen 16 bit accesses
> (readw/writew) in Bhupesh's driver.

Doh....I, never having programmed under Windows or DOS, always mixes up
the width of these read{b,w,l}.

Marc

-- 
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