2
votes

I have gone through some driver implementation in Linux Kernel Source and can see that these are the platform driver.

drivers/net/ethernet/smsc/smsc911x.c

  static struct platform_driver smc911x_driver = {
    .probe           = smc911x_drv_probe,
    .remove  = smc911x_drv_remove,
    .suspend         = smc911x_drv_suspend,
    .resume  = smc911x_drv_resume,
    .driver  = {
            .name    = CARDNAME,
            .owner  = THIS_MODULE,
    },
};

Above is a driver for platform device(smsc based Ethernet controller) and platform devices are devices which are not probed automatically during system boot-up unlike legacy devices sitting on the pci bus.

I guess this understanding of mine is OK here?

Now when I say it is the platform devices, is it mean these devices(Ethernet Controller) are sitting on Platform bus and on ARM architecture default platform bus is AMBA.

So when we solder the Ethernet controller on ARM based board it should be sit on or interfaced with AMBA bus?

How Do we decide that driver we're going to write is Platform driver or Normal driver?

1
See this closed question, where I answered this. You must add a platform_register_device() to your machine file. See: platform driver documenation for instance. If there is no bus that will probe the hardware, then you must use a platform device.artless noise
OK, @artless have gone through closed question which you have answered and have some doubts after it.Platform devices are not associated with any bus but are associated with platform bus?What are the platform bus?Also when you say platform devices are integrated with CPU ,is it mean platform devices are on same black chip where cpu is and not on same green die?Amit Singh Tomar
Read driver model overview. A typical PC (Linux heritage) has a PCI bus; many Linux drivers are for PCI cards.artless noise
platform bus is a synthetic bus; Ie, the Linux driver model wants each device to be connected to a bus. The plaform bus is for when there is no supported bus. From the documentation What they usually have in common is direct addressing from a CPU bus., which is what your AMBA device is. Compare to a PCI, USB, SPI, I2C, etc bus where there is a common BUS that connect the chip to the CPU. Do you mean green board? You can't answer like that. An Ethernet MII is a BUS, but it is not a topology supported by Linux. Ie, you can have extra chips. You can't look at a board and tell.artless noise
Thanks @artlessnoise,I think I got your point or may be not .Let me just place my understanding before you, platform devices are the one which directly connects to CPU chip without buses like PCI, USB,SPI,I2C and just like AMBA devices Platform devices have direct addressing from CPU bus(To be honest I didn't get this point).Is it like platform device's register are accessible over links like xio or MII?Amit Singh Tomar

1 Answers

2
votes

From my limited experience in developing ARM platform drivers, AMBA devices typically have identification registers at the end of their memory mapped IO register interface.

Generally speaking, if you look at the reference manual for your ethernet controller and register summary specifies peripheral/component identification registers (usually at offsets 0xFE0-0xFEC and 0xFF0-0xFFC), you should write an AMBA bus driver. These drivers can be identified automatically by the bus driver.

Otherwise, if the register interface doesn't specify any ID registers at offsets 0xFE0-0xFEC and 0xFF0-0xFFC, you'll probably just want to write a platform driver. These devices cannot be automatically identified and you need to specifically attach a driver to the device.