2 * MFD driver for wl1273 FM radio and audio codec submodules.
4 * Copyright (C) 2010 Nokia Corporation
5 * Author: Matti Aaltonen <matti.j.aaltonen@nokia.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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 Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 #include <linux/mfd/wl1273-core.h>
24 #include <linux/slab.h>
26 #define DRIVER_DESC "WL1273 FM Radio Core"
28 static struct i2c_device_id wl1273_driver_id_table[] = {
29 { WL1273_FM_DRIVER_NAME, 0 },
32 MODULE_DEVICE_TABLE(i2c, wl1273_driver_id_table);
34 static int wl1273_core_remove(struct i2c_client *client)
36 struct wl1273_core *core = i2c_get_clientdata(client);
38 dev_dbg(&client->dev, "%s\n", __func__);
40 mfd_remove_devices(&client->dev);
46 static int __devinit wl1273_core_probe(struct i2c_client *client,
47 const struct i2c_device_id *id)
49 struct wl1273_fm_platform_data *pdata = client->dev.platform_data;
50 struct wl1273_core *core;
51 struct mfd_cell *cell;
55 dev_dbg(&client->dev, "%s\n", __func__);
58 dev_err(&client->dev, "No platform data.\n");
62 if (!(pdata->children & WL1273_RADIO_CHILD)) {
63 dev_err(&client->dev, "Cannot function without radio child.\n");
67 core = kzalloc(sizeof(*core), GFP_KERNEL);
72 core->client = client;
73 mutex_init(&core->lock);
75 i2c_set_clientdata(client, core);
77 dev_dbg(&client->dev, "%s: Have V4L2.\n", __func__);
79 cell = &core->cells[children];
80 cell->name = "wl1273_fm_radio";
81 cell->platform_data = &core;
82 cell->data_size = sizeof(core);
85 if (pdata->children & WL1273_CODEC_CHILD) {
86 cell = &core->cells[children];
88 dev_dbg(&client->dev, "%s: Have codec.\n", __func__);
89 cell->name = "wl1273-codec";
90 cell->platform_data = &core;
91 cell->data_size = sizeof(core);
95 dev_dbg(&client->dev, "%s: number of children: %d.\n",
98 r = mfd_add_devices(&client->dev, -1, core->cells,
106 pdata->free_resources();
109 dev_dbg(&client->dev, "%s\n", __func__);
114 static struct i2c_driver wl1273_core_driver = {
116 .name = WL1273_FM_DRIVER_NAME,
118 .probe = wl1273_core_probe,
119 .id_table = wl1273_driver_id_table,
120 .remove = __devexit_p(wl1273_core_remove),
123 static int __init wl1273_core_init(void)
127 r = i2c_add_driver(&wl1273_core_driver);
129 pr_err(WL1273_FM_DRIVER_NAME
130 ": driver registration failed\n");
137 static void __exit wl1273_core_exit(void)
139 i2c_del_driver(&wl1273_core_driver);
141 late_initcall(wl1273_core_init);
142 module_exit(wl1273_core_exit);
144 MODULE_AUTHOR("Matti Aaltonen <matti.j.aaltonen@nokia.com>");
145 MODULE_DESCRIPTION(DRIVER_DESC);
146 MODULE_LICENSE("GPL");