Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / wireless / b43 / bus.c
1 /*
2
3 Broadcom B43 wireless driver
4 Bus abstraction layer
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 */
22
23 #include "b43.h"
24 #include "bus.h"
25
26
27 /* SSB */
28
29 static inline int b43_bus_ssb_bus_may_powerdown(struct b43_bus_dev *dev)
30 {
31 return ssb_bus_may_powerdown(dev->sdev->bus);
32 }
33 static inline int b43_bus_ssb_bus_powerup(struct b43_bus_dev *dev,
34 bool dynamic_pctl)
35 {
36 return ssb_bus_powerup(dev->sdev->bus, dynamic_pctl);
37 }
38 static inline int b43_bus_ssb_device_is_enabled(struct b43_bus_dev *dev)
39 {
40 return ssb_device_is_enabled(dev->sdev);
41 }
42 static inline void b43_bus_ssb_device_enable(struct b43_bus_dev *dev,
43 u32 core_specific_flags)
44 {
45 ssb_device_enable(dev->sdev, core_specific_flags);
46 }
47 static inline void b43_bus_ssb_device_disable(struct b43_bus_dev *dev,
48 u32 core_specific_flags)
49 {
50 ssb_device_disable(dev->sdev, core_specific_flags);
51 }
52
53 static inline u16 b43_bus_ssb_read16(struct b43_bus_dev *dev, u16 offset)
54 {
55 return ssb_read16(dev->sdev, offset);
56 }
57 static inline u32 b43_bus_ssb_read32(struct b43_bus_dev *dev, u16 offset)
58 {
59 return ssb_read32(dev->sdev, offset);
60 }
61 static inline
62 void b43_bus_ssb_write16(struct b43_bus_dev *dev, u16 offset, u16 value)
63 {
64 ssb_write16(dev->sdev, offset, value);
65 }
66 static inline
67 void b43_bus_ssb_write32(struct b43_bus_dev *dev, u16 offset, u32 value)
68 {
69 ssb_write32(dev->sdev, offset, value);
70 }
71 static inline
72 void b43_bus_ssb_block_read(struct b43_bus_dev *dev, void *buffer,
73 size_t count, u16 offset, u8 reg_width)
74 {
75 ssb_block_read(dev->sdev, buffer, count, offset, reg_width);
76 }
77 static inline
78 void b43_bus_ssb_block_write(struct b43_bus_dev *dev, const void *buffer,
79 size_t count, u16 offset, u8 reg_width)
80 {
81 ssb_block_write(dev->sdev, buffer, count, offset, reg_width);
82 }
83
84 struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev)
85 {
86 struct b43_bus_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
87
88 dev->bus_type = B43_BUS_SSB;
89 dev->sdev = sdev;
90
91 dev->bus_may_powerdown = b43_bus_ssb_bus_may_powerdown;
92 dev->bus_powerup = b43_bus_ssb_bus_powerup;
93 dev->device_is_enabled = b43_bus_ssb_device_is_enabled;
94 dev->device_enable = b43_bus_ssb_device_enable;
95 dev->device_disable = b43_bus_ssb_device_disable;
96
97 dev->read16 = b43_bus_ssb_read16;
98 dev->read32 = b43_bus_ssb_read32;
99 dev->write16 = b43_bus_ssb_write16;
100 dev->write32 = b43_bus_ssb_write32;
101 dev->block_read = b43_bus_ssb_block_read;
102 dev->block_write = b43_bus_ssb_block_write;
103
104 dev->dev = sdev->dev;
105 dev->dma_dev = sdev->dma_dev;
106 dev->irq = sdev->irq;
107
108 dev->board_vendor = sdev->bus->boardinfo.vendor;
109 dev->board_type = sdev->bus->boardinfo.type;
110 dev->board_rev = sdev->bus->boardinfo.rev;
111
112 dev->chip_id = sdev->bus->chip_id;
113 dev->chip_rev = sdev->bus->chip_rev;
114 dev->chip_pkg = sdev->bus->chip_package;
115
116 dev->bus_sprom = &sdev->bus->sprom;
117
118 dev->core_id = sdev->id.coreid;
119 dev->core_rev = sdev->id.revision;
120
121 return dev;
122 }