2 ---------- Devices and drivers in barebox --------------
4 We follow a rather simplistic driver model here. There is a struct device which
5 describes a particular device present in the system. A struct driver represents
6 a driver present in the system. Both structs find together via the members
7 'type' (int) and 'name' (char *). If both members match, the driver's probe
8 function is called with the struct device as argument. People familiar with
9 the Linux platform bus will recognize this behaviour and in fact many things were
10 stolen from there. Some selected members of the structs will be described in this
12 Currently all devices and drivers are handled in simple linked lists. When it comes
13 to USB or PCI it may be desirable to have a tree structure, but this may also be
19 char name[MAX_DRIVER_NAME];
21 This member (and 'type' described below) is used to match with a driver. This is
22 a descriptive name and could be MPC5XXX_ether or imx_serial.
24 char id[MAX_DRIVER_NAME];
26 The id is used to uniquely identify a device in the system. The id will show up
27 under /dev/ as the device's name. Usually this is something like eth0 or nor0.
31 Devices of a particular class normaly need to store more information than struct
32 device holds. This entry holds a pointer to the type specific struct.
36 Used by the device driver to store private information.
40 This is used to carry information of board specific data from the board code to the
43 struct param_d *param;
45 The parameters for this device. See Documentation/parameters.txt for more info.
50 char name[MAX_DRIVER_NAME];
55 int (*probe) (struct device_d *);
56 int (*remove)(struct device_d *);
58 These are called if an instance of a device is found or gone.
60 ssize_t (*read) (struct device_d*, void* buf, size_t count, ulong offset, ulong flags);
61 ssize_t (*write) (struct device_d*, const void* buf, size_t count, ulong offset, ulong flags);
63 The standard read/write functions. These are called as a response to the read/write
64 system calls. No driver needs to implement these.
68 This is somewhat redundant with the type data in struct device. Currently the
69 filesystem implementation uses this field while ethernet drivers use the same
70 field in struct device. Probably one of them should be removed.