Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Driver for the charging sensor on the N900

Am 14.04.13 20:47, schrieb Pierre Pronchery:
>                       Hi current-users@,
> I am slowly understanding how to write the first batch of drivers for
> the Nokia N900, starting with what's available on the main GPIO pins.
> The driver attached signals whenever the device is connected to a
> charger and reports it to envsys. It requires the following changes to
> function properly:
> in sys/arch/evbarm/conf/N900:
> # GPIO devices
> # Charging sensor
> n900acad0       at gpio0 offset 7 mask 0x1 #intr 103
> in sys/arch/evbarm/conf/files.n900:
> # Charging sensor
> device n900acad: sysmon_envsys
> attach n900acad at gpio with n900acad
> file    arch/evbarm/n900/n900_acad.c            n900acad
> and then the driver code attached goes into arch/evbarm/n900/n900_acad.c.
> Before committing anything, I would like to know if I have done things
> properly there:
> - the GPIO pin is mapped as interrupt 103 (omapgpio0, offset 7)
> - the driver uses intr_establish() to hook it;
> - it also configures and uses that same pin as an input.
> The ugly part is when calling intr_establish(), where I had to hard-code
> omapgpio0's base interrupt (96).

That is ugly indeed.  A very first step would be to #define any magic
numbers (96 in this case), and add a comment what they mean.

As more and more gpios are interrupt capable, that should find it's way
into gpio(4).  I got me some hardware to work on this, the
non-interrupt-capabilities of gpio(4) is a long-standing bug, imo.

> Is there a better way to do this?
> Cheers,

Home | Main Index | Thread Index | Old Index