driver: add dev_name inline
[barebox-mini2440.git] / Documentation / devices_drivers.txt
blob06e788de860635515853ebd34cc7282d2541cd03
2 ---------- Devices and drivers in U-Boot --------------
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
11 document.
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
14 unnecessary overhead.
16 struct device
17 -------------
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.
29 void *type_data;
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.
34 void *priv;
36 Used by the device driver to store private information.
38 void *platform_data;
40 This is used to carry information of board specific data from the board code to the
41 device driver.
43 struct param_d *param;
45 The parameters for this device. See Documentation/parameters.txt for more info.
47 struct driver_d
48 ---------------
50 char name[MAX_DRIVER_NAME];
51 unsigned long type;
53 See above.
55 int     (*probe) (struct device_d *);
56 int     (*remove)(struct device_d *);
58 These are called if a 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.
66 void *type_data;
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 both should be removed.