xref: /OK3568_Linux_fs/kernel/Documentation/pcmcia/driver-changes.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun==============
2*4882a593SmuzhiyunDriver changes
3*4882a593Smuzhiyun==============
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThis file details changes in 2.6 which affect PCMCIA card driver authors:
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun* pcmcia_loop_config() and autoconfiguration (as of 2.6.36)
8*4882a593Smuzhiyun   If `struct pcmcia_device *p_dev->config_flags` is set accordingly,
9*4882a593Smuzhiyun   pcmcia_loop_config() now sets up certain configuration values
10*4882a593Smuzhiyun   automatically, though the driver may still override the settings
11*4882a593Smuzhiyun   in the callback function. The following autoconfiguration options
12*4882a593Smuzhiyun   are provided at the moment:
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun	- CONF_AUTO_CHECK_VCC : check for matching Vcc
15*4882a593Smuzhiyun	- CONF_AUTO_SET_VPP   : set Vpp
16*4882a593Smuzhiyun	- CONF_AUTO_AUDIO     : auto-enable audio line, if required
17*4882a593Smuzhiyun	- CONF_AUTO_SET_IO    : set ioport resources (->resource[0,1])
18*4882a593Smuzhiyun	- CONF_AUTO_SET_IOMEM : set first iomem resource (->resource[2])
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun* pcmcia_request_configuration -> pcmcia_enable_device (as of 2.6.36)
21*4882a593Smuzhiyun   pcmcia_request_configuration() got renamed to pcmcia_enable_device(),
22*4882a593Smuzhiyun   as it mirrors pcmcia_disable_device(). Configuration settings are now
23*4882a593Smuzhiyun   stored in struct pcmcia_device, e.g. in the fields config_flags,
24*4882a593Smuzhiyun   config_index, config_base, vpp.
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun* pcmcia_request_window changes (as of 2.6.36)
27*4882a593Smuzhiyun   Instead of win_req_t, drivers are now requested to fill out
28*4882a593Smuzhiyun   `struct pcmcia_device *p_dev->resource[2,3,4,5]` for up to four ioport
29*4882a593Smuzhiyun   ranges. After a call to pcmcia_request_window(), the regions found there
30*4882a593Smuzhiyun   are reserved and may be used immediately -- until pcmcia_release_window()
31*4882a593Smuzhiyun   is called.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun* pcmcia_request_io changes (as of 2.6.36)
34*4882a593Smuzhiyun   Instead of io_req_t, drivers are now requested to fill out
35*4882a593Smuzhiyun   `struct pcmcia_device *p_dev->resource[0,1]` for up to two ioport
36*4882a593Smuzhiyun   ranges. After a call to pcmcia_request_io(), the ports found there
37*4882a593Smuzhiyun   are reserved, after calling pcmcia_request_configuration(), they may
38*4882a593Smuzhiyun   be used.
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun* No dev_info_t, no cs_types.h (as of 2.6.36)
41*4882a593Smuzhiyun   dev_info_t and a few other typedefs are removed. No longer use them
42*4882a593Smuzhiyun   in PCMCIA device drivers. Also, do not include pcmcia/cs_types.h, as
43*4882a593Smuzhiyun   this file is gone.
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun* No dev_node_t (as of 2.6.35)
46*4882a593Smuzhiyun   There is no more need to fill out a "dev_node_t" structure.
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun* New IRQ request rules (as of 2.6.35)
49*4882a593Smuzhiyun   Instead of the old pcmcia_request_irq() interface, drivers may now
50*4882a593Smuzhiyun   choose between:
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun   - calling request_irq/free_irq directly. Use the IRQ from `*p_dev->irq`.
53*4882a593Smuzhiyun   - use pcmcia_request_irq(p_dev, handler_t); the PCMCIA core will
54*4882a593Smuzhiyun     clean up automatically on calls to pcmcia_disable_device() or
55*4882a593Smuzhiyun     device ejection.
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun* no cs_error / CS_CHECK / CONFIG_PCMCIA_DEBUG (as of 2.6.33)
58*4882a593Smuzhiyun   Instead of the cs_error() callback or the CS_CHECK() macro, please use
59*4882a593Smuzhiyun   Linux-style checking of return values, and -- if necessary -- debug
60*4882a593Smuzhiyun   messages using "dev_dbg()" or "pr_debug()".
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun* New CIS tuple access (as of 2.6.33)
63*4882a593Smuzhiyun   Instead of pcmcia_get_{first,next}_tuple(), pcmcia_get_tuple_data() and
64*4882a593Smuzhiyun   pcmcia_parse_tuple(), a driver shall use "pcmcia_get_tuple()" if it is
65*4882a593Smuzhiyun   only interested in one (raw) tuple, or "pcmcia_loop_tuple()" if it is
66*4882a593Smuzhiyun   interested in all tuples of one type. To decode the MAC from CISTPL_FUNCE,
67*4882a593Smuzhiyun   a new helper "pcmcia_get_mac_from_cis()" was added.
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun* New configuration loop helper (as of 2.6.28)
70*4882a593Smuzhiyun   By calling pcmcia_loop_config(), a driver can iterate over all available
71*4882a593Smuzhiyun   configuration options. During a driver's probe() phase, one doesn't need
72*4882a593Smuzhiyun   to use pcmcia_get_{first,next}_tuple, pcmcia_get_tuple_data and
73*4882a593Smuzhiyun   pcmcia_parse_tuple directly in most if not all cases.
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun* New release helper (as of 2.6.17)
76*4882a593Smuzhiyun   Instead of calling pcmcia_release_{configuration,io,irq,win}, all that's
77*4882a593Smuzhiyun   necessary now is calling pcmcia_disable_device. As there is no valid
78*4882a593Smuzhiyun   reason left to call pcmcia_release_io and pcmcia_release_irq, the
79*4882a593Smuzhiyun   exports for them were removed.
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun* Unify detach and REMOVAL event code, as well as attach and INSERTION
82*4882a593Smuzhiyun  code (as of 2.6.16)::
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun       void (*remove)          (struct pcmcia_device *dev);
85*4882a593Smuzhiyun       int (*probe)            (struct pcmcia_device *dev);
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun* Move suspend, resume and reset out of event handler (as of 2.6.16)::
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun       int (*suspend)          (struct pcmcia_device *dev);
90*4882a593Smuzhiyun       int (*resume)           (struct pcmcia_device *dev);
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun  should be initialized in struct pcmcia_driver, and handle
93*4882a593Smuzhiyun  (SUSPEND == RESET_PHYSICAL) and (RESUME == CARD_RESET) events
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun* event handler initialization in struct pcmcia_driver (as of 2.6.13)
96*4882a593Smuzhiyun   The event handler is notified of all events, and must be initialized
97*4882a593Smuzhiyun   as the event() callback in the driver's struct pcmcia_driver.
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun* pcmcia/version.h should not be used (as of 2.6.13)
100*4882a593Smuzhiyun   This file will be removed eventually.
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun* in-kernel device<->driver matching (as of 2.6.13)
103*4882a593Smuzhiyun   PCMCIA devices and their correct drivers can now be matched in
104*4882a593Smuzhiyun   kernelspace. See 'devicetable.txt' for details.
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun* Device model integration (as of 2.6.11)
107*4882a593Smuzhiyun   A struct pcmcia_device is registered with the device model core,
108*4882a593Smuzhiyun   and can be used (e.g. for SET_NETDEV_DEV) by using
109*4882a593Smuzhiyun   handle_to_dev(client_handle_t * handle).
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun* Convert internal I/O port addresses to unsigned int (as of 2.6.11)
112*4882a593Smuzhiyun   ioaddr_t should be replaced by unsigned int in PCMCIA card drivers.
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun* irq_mask and irq_list parameters (as of 2.6.11)
115*4882a593Smuzhiyun   The irq_mask and irq_list parameters should no longer be used in
116*4882a593Smuzhiyun   PCMCIA card drivers. Instead, it is the job of the PCMCIA core to
117*4882a593Smuzhiyun   determine which IRQ should be used. Therefore, link->irq.IRQInfo2
118*4882a593Smuzhiyun   is ignored.
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun* client->PendingEvents is gone (as of 2.6.11)
121*4882a593Smuzhiyun   client->PendingEvents is no longer available.
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun* client->Attributes are gone (as of 2.6.11)
124*4882a593Smuzhiyun   client->Attributes is unused, therefore it is removed from all
125*4882a593Smuzhiyun   PCMCIA card drivers
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun* core functions no longer available (as of 2.6.11)
128*4882a593Smuzhiyun   The following functions have been removed from the kernel source
129*4882a593Smuzhiyun   because they are unused by all in-kernel drivers, and no external
130*4882a593Smuzhiyun   driver was reported to rely on them::
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun	pcmcia_get_first_region()
133*4882a593Smuzhiyun	pcmcia_get_next_region()
134*4882a593Smuzhiyun	pcmcia_modify_window()
135*4882a593Smuzhiyun	pcmcia_set_event_mask()
136*4882a593Smuzhiyun	pcmcia_get_first_window()
137*4882a593Smuzhiyun	pcmcia_get_next_window()
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun* device list iteration upon module removal (as of 2.6.10)
140*4882a593Smuzhiyun   It is no longer necessary to iterate on the driver's internal
141*4882a593Smuzhiyun   client list and call the ->detach() function upon module removal.
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun* Resource management. (as of 2.6.8)
144*4882a593Smuzhiyun   Although the PCMCIA subsystem will allocate resources for cards,
145*4882a593Smuzhiyun   it no longer marks these resources busy. This means that driver
146*4882a593Smuzhiyun   authors are now responsible for claiming your resources as per
147*4882a593Smuzhiyun   other drivers in Linux. You should use request_region() to mark
148*4882a593Smuzhiyun   your IO regions in-use, and request_mem_region() to mark your
149*4882a593Smuzhiyun   memory regions in-use. The name argument should be a pointer to
150*4882a593Smuzhiyun   your driver name. Eg, for pcnet_cs, name should point to the
151*4882a593Smuzhiyun   string "pcnet_cs".
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun* CardServices is gone
154*4882a593Smuzhiyun  CardServices() in 2.4 is just a big switch statement to call various
155*4882a593Smuzhiyun  services.  In 2.6, all of those entry points are exported and called
156*4882a593Smuzhiyun  directly (except for pcmcia_report_error(), just use cs_error() instead).
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun* struct pcmcia_driver
159*4882a593Smuzhiyun  You need to use struct pcmcia_driver and pcmcia_{un,}register_driver
160*4882a593Smuzhiyun  instead of {un,}register_pccard_driver
161