2 Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
3 Copyright (C) 2004 - 2009 Felix Fietkau <nbd@openwrt.org>
4 <http://rt2x00.serialmonkey.com>
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the
18 Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 Abstract: rt2x00 generic soc device routines.
27 #include <linux/bug.h>
28 #include <linux/kernel.h>
29 #include <linux/module.h>
30 #include <linux/platform_device.h>
31 #include <linux/slab.h>
34 #include "rt2x00soc.h"
36 static void rt2x00soc_free_reg(struct rt2x00_dev
*rt2x00dev
)
41 kfree(rt2x00dev
->eeprom
);
42 rt2x00dev
->eeprom
= NULL
;
44 iounmap(rt2x00dev
->csr
.base
);
47 static int rt2x00soc_alloc_reg(struct rt2x00_dev
*rt2x00dev
)
49 struct platform_device
*pdev
= to_platform_device(rt2x00dev
->dev
);
52 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
56 rt2x00dev
->csr
.base
= ioremap(res
->start
, resource_size(res
));
57 if (!rt2x00dev
->csr
.base
)
60 rt2x00dev
->eeprom
= kzalloc(rt2x00dev
->ops
->eeprom_size
, GFP_KERNEL
);
61 if (!rt2x00dev
->eeprom
)
64 rt2x00dev
->rf
= kzalloc(rt2x00dev
->ops
->rf_size
, GFP_KERNEL
);
71 ERROR_PROBE("Failed to allocate registers.\n");
72 rt2x00soc_free_reg(rt2x00dev
);
77 int rt2x00soc_probe(struct platform_device
*pdev
, const struct rt2x00_ops
*ops
)
79 struct ieee80211_hw
*hw
;
80 struct rt2x00_dev
*rt2x00dev
;
83 hw
= ieee80211_alloc_hw(sizeof(struct rt2x00_dev
), ops
->hw
);
85 ERROR_PROBE("Failed to allocate hardware.\n");
89 platform_set_drvdata(pdev
, hw
);
92 rt2x00dev
->dev
= &pdev
->dev
;
95 rt2x00dev
->irq
= platform_get_irq(pdev
, 0);
96 rt2x00dev
->name
= pdev
->dev
.driver
->name
;
98 rt2x00_set_chip_intf(rt2x00dev
, RT2X00_CHIP_INTF_SOC
);
100 retval
= rt2x00soc_alloc_reg(rt2x00dev
);
102 goto exit_free_device
;
104 retval
= rt2x00lib_probe_dev(rt2x00dev
);
111 rt2x00soc_free_reg(rt2x00dev
);
114 ieee80211_free_hw(hw
);
118 EXPORT_SYMBOL_GPL(rt2x00soc_probe
);
120 int rt2x00soc_remove(struct platform_device
*pdev
)
122 struct ieee80211_hw
*hw
= platform_get_drvdata(pdev
);
123 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
126 * Free all allocated data.
128 rt2x00lib_remove_dev(rt2x00dev
);
129 rt2x00soc_free_reg(rt2x00dev
);
130 ieee80211_free_hw(hw
);
134 EXPORT_SYMBOL_GPL(rt2x00soc_remove
);
137 int rt2x00soc_suspend(struct platform_device
*pdev
, pm_message_t state
)
139 struct ieee80211_hw
*hw
= platform_get_drvdata(pdev
);
140 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
142 return rt2x00lib_suspend(rt2x00dev
, state
);
144 EXPORT_SYMBOL_GPL(rt2x00soc_suspend
);
146 int rt2x00soc_resume(struct platform_device
*pdev
)
148 struct ieee80211_hw
*hw
= platform_get_drvdata(pdev
);
149 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
151 return rt2x00lib_resume(rt2x00dev
);
153 EXPORT_SYMBOL_GPL(rt2x00soc_resume
);
154 #endif /* CONFIG_PM */
157 * rt2x00soc module information.
159 MODULE_AUTHOR(DRV_PROJECT
);
160 MODULE_VERSION(DRV_VERSION
);
161 MODULE_DESCRIPTION("rt2x00 soc library");
162 MODULE_LICENSE("GPL");