If the driver does not exist in the kernel source tree, and the device is memory mapped in the device address space, then the device resources (adress region, irq lines) has to be declared somewhere. In older version of the kernel, this was the responsibility of the board file, but now it has moved to the device tree.
So the main difference with x86 architecture is not how you write a driver, but rather how you match devices and driver. On x86, you have for instance pci driver, and pci devices that are discoverable. On ARM, there is generally no such self describing hardware, and to emulate the whole device / driver dance, the platform bus was created.
So a typical device driver on ARM is a platform driver, and the associated devices are platform devices. An example ethernet mac driver from the current kernel is here.
In the above linked driver, the driver code doesn't know where the device lives. This info is passed to the driver at probe time, using the platform_device
object. And the platform device can be described like this (source):
static struct platform_device at91sam9260_eth_device = {
.name = "macb",
.id = -1,
.dev = {
.dma_mask = ð_dmamask,
.coherent_dma_mask = DMA_BIT_MASK(32),
.platform_data = ð_data,
},
.resource = eth_resources,
.num_resources = ARRAY_SIZE(eth_resources),
};
Platform device can be created from c code as shown here, or they can be described in device tree. In both cases, you won't see anything in proc/iomem until the device has been probed by the driver. This his in contrast with the x86 world where most devices are PCI devices.
Here is the same device, but described in a device tree file :
macb0: ethernet@fffc4000 {
compatible = "cdns,at32ap7000-macb", "cdns,macb";
reg = <0xfffc4000 0x100>;
interrupts = <21 IRQ_TYPE_LEVEL_HIGH 3>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_macb_rmii>;
status = "disabled";
};