ts-7000
[Top] [All Lists]

[ts-7000] Re: Help - confused by platform driver code.

To:
Subject: [ts-7000] Re: Help - confused by platform driver code.
From: "Dom Storey" <>
Date: Wed, 03 Mar 2010 07:10:07 -0000
I got the driver working now, with one exception. I also tried to create a test 
function in arch/arm/mach-ep93xx/include/mach/ts72xx.h that looked like this:


#define TS72XX_PC104_8BIT_IO_VIRT_BASE  0xfebf0000
#define TS72XX_PC104_8BIT_IO_PHYS_BASE  0x11e00000
#define TS72XX_RELAY8_ID                0x9B
#define TS72XX_RELAY8_BOARD1            0x140   /* JP1=OFF, JP2=OFF */
#define TS72XX_RELAY8_BOARD2            0x150   /* JP1=ON,  JP2=OFF */
#define TS72XX_RELAY8_BOARD3            0x160   /* JP1=OFF, JP2=ON  */
#define TS72XX_RELAY8_BOARD4            0x170   /* JP1=ON,  JP2=ON  */

  ....

static inline int is_relay8_installed(void)
{
        printk("in inline_int_is_relay8_installed()\n");
        return (
                ((__raw_readb(TS72XX_PC104_8BIT_IO_VIRT_BASE + 
TS72XX_RELAY8_BOARD4) == TS72XX_RELAY8_ID) << 3) |
                ((__raw_readb(TS72XX_PC104_8BIT_IO_VIRT_BASE + 
TS72XX_RELAY8_BOARD3) == TS72XX_RELAY8_ID) << 2) |
                ((__raw_readb(TS72XX_PC104_8BIT_IO_VIRT_BASE + 
TS72XX_RELAY8_BOARD2) == TS72XX_RELAY8_ID) << 1) |
                ((__raw_readb(TS72XX_PC104_8BIT_IO_VIRT_BASE + 
TS72XX_RELAY8_BOARD1) == TS72XX_RELAY8_ID) << 0)
        );
}

It was based on the other test routines in the header function. I wanted to 
create a bit mask to identify how many boards were installed (you can have 4 of 
them).

Then I called this function in ts72xx_init_machine() (file 
arch/arm/mach-ep93xx/ts72xx.c)

static void __init ts72xx_init_machine(void)
{
        ep93xx_init_devices();
        ts72xx_register_flash();
        platform_device_register(&ts72xx_rtc_device);

        ep93xx_register_i2c(&ts72xx_i2c_gpio_data,
                        ts72xx_i2c_board_info,
                        ARRAY_SIZE(ts72xx_i2c_board_info));
        ep93xx_register_eth(&ts72xx_eth_data, 1);

        #if defined(CONFIG_SPI_TMP124) || defined(CONFIG_SPI_TMP124_MODULE)
        spi_register_board_info(ts72xx_spi_bus,
                        ARRAY_SIZE(ts72xx_spi_bus));
        #endif

        /* PWM1 is DIO_6 on TS-72xx header */
        ep93xx_register_pwm(0, 1);

        /* added D.P.Storey */

        if (is_max197_installed())
               platform_device_register(&ts72xx_max197_device);
        
        if (is_relay8_installed()){
                printk("ts72xx.ko: registering ts72xx_relay8.ko\n");
                platform_device_register(&ts72xx_relay8_device);
        }
        
}

Unfortunately, it caused my kernel to hang on boot. It would just sit quiet 
after printing the dots and the "booting linux,done" message.  I tried 
substituting the  TS72XX_PC104_8BIT_IO_PHYS_BASE instead of 
TS72XX_PC104_8BIT_IO_VIRT_BASE in is_relay8_installed(void) but with the same 
result, so now I have just commented out the call to this function and I always 
register the device.

It seems to me that this architecture is defeating the point of modules. Why 
would you want to register one module in a separate function (e.g. 
platform_device_register() in ts72xx.c). Can't this all be done in the module 
itself?

Can anyone help me figure out how to fix is_relay8_installed()?  I'm sure that 
somewhere an ioremap() or two is missing. Once I'm done, I'll post the driver 
to the group.

thanks Dom


--- In  "Sandesh Ghimire" <> wrote:
>
> 
>
> 
>
> From:   On Behalf Of
> Petr ©tetiar
> Sent: Sunday, February 28, 2010 7:31 AM
> To: 
> Subject: Re: [ts-7000] Help - confused by platform driver code.
>
> 
>
>  
>
> Dom Storey < <dstorey%40barossafarm.com> >
> [2010-02-28 07:08:38]:
>
> > This location should be done in the probe routine of the driver. Yet on
> all
> > the other drivers I have examined, I can't see how they locate specific
> > locations in memory.
>
> Take a look at Matthieu's patches[1], for example at his
> 0006-ts72xx_ts_ser1.patch.
>
> > Most drivers seem to have
> >
> > r_data = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>
> but to use this, you would need to define resource first:
>
> static struct resource ts72xx_mydrv_resources[] = {
> {
> .start = TS72XX_PC104_8BIT_IO_PHYS_BASE,
> .end = TS72XX_PC104_8BIT_IO_PHYS_BASE + TS72XX_PC104_8BIT_IO_SIZE,
> .flags = IORESOURCE_MEM,
> }
>
> then assign the resource to your platform_device:
>
> static struct platform_device ts72xx_mydrv_device = {
> .resource = ts72xx_mydrv_resources,
> .num_resources = ARRAY_SIZE(ts72xx_mydrv_resources),
> }
>
> then register it:
>
> platform_device_register(&ts72xx_mydrv_device);
>
> and now you can do:
>
> mem_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>
> But I think, that you can do it easily using ioremap, __raw{read, write}b as
> Matthieu is doing in his ts_ser1 driver.
>
> 1. http://mcrapet.free.fr/
>
> -- ynezz
>




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
    
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU