2 * This file is part of wl18xx
4 * Copyright (C) 2011 Texas Instruments
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include <linux/module.h>
23 #include <linux/platform_device.h>
25 #include "../wlcore/wlcore.h"
26 #include "../wlcore/debug.h"
27 #include "../wlcore/io.h"
28 #include "../wlcore/acx.h"
29 #include "../wlcore/boot.h"
35 static struct wl18xx_conf wl18xx_default_conf
= {
37 .phy_standalone
= 0x00,
38 .primary_clock_setting_time
= 0x05,
39 .clock_valid_on_wake_up
= 0x00,
40 .secondary_clock_setting_time
= 0x05,
43 .dedicated_fem
= FEM_NONE
,
44 .low_band_component
= COMPONENT_2_WAY_SWITCH
,
45 .low_band_component_type
= 0x05,
46 .high_band_component
= COMPONENT_2_WAY_SWITCH
,
47 .high_band_component_type
= 0x09,
48 .number_of_assembled_ant2_4
= 0x01,
49 .number_of_assembled_ant5
= 0x01,
50 .external_pa_dc2dc
= 0x00,
51 .tcxo_ldo_voltage
= 0x00,
52 .xtal_itrim_val
= 0x04,
54 .io_configuration
= 0x01,
55 .sdio_configuration
= 0x00,
58 .enable_tx_low_pwr_on_siso_rdl
= 0x00,
63 static const struct wlcore_partition_set wl18xx_ptable
[PART_TABLE_LEN
] = {
64 [PART_TOP_PRCM_ELP_SOC
] = {
65 .mem
= { .start
= 0x00A02000, .size
= 0x00010000 },
66 .reg
= { .start
= 0x00807000, .size
= 0x00005000 },
67 .mem2
= { .start
= 0x00800000, .size
= 0x0000B000 },
68 .mem3
= { .start
= 0x00000000, .size
= 0x00000000 },
71 .mem
= { .start
= 0x00000000, .size
= 0x00014000 },
72 .reg
= { .start
= 0x00810000, .size
= 0x0000BFFF },
73 .mem2
= { .start
= 0x00000000, .size
= 0x00000000 },
74 .mem3
= { .start
= 0x00000000, .size
= 0x00000000 },
77 .mem
= { .start
= 0x00700000, .size
= 0x0000030c },
78 .reg
= { .start
= 0x00802000, .size
= 0x00014578 },
79 .mem2
= { .start
= 0x00B00404, .size
= 0x00001000 },
80 .mem3
= { .start
= 0x00C00000, .size
= 0x00000400 },
83 .mem
= { .start
= 0x00800000, .size
= 0x000050FC },
84 .reg
= { .start
= 0x00B00404, .size
= 0x00001000 },
85 .mem2
= { .start
= 0x00C00000, .size
= 0x00000400 },
86 .mem3
= { .start
= 0x00000000, .size
= 0x00000000 },
89 /* TODO: use the phy_conf struct size here */
90 .mem
= { .start
= 0x80926000, .size
= 252 },
91 .reg
= { .start
= 0x00000000, .size
= 0x00000000 },
92 .mem2
= { .start
= 0x00000000, .size
= 0x00000000 },
93 .mem3
= { .start
= 0x00000000, .size
= 0x00000000 },
97 static const int wl18xx_rtable
[REG_TABLE_LEN
] = {
98 [REG_ECPU_CONTROL
] = WL18XX_REG_ECPU_CONTROL
,
99 [REG_INTERRUPT_NO_CLEAR
] = WL18XX_REG_INTERRUPT_NO_CLEAR
,
100 [REG_INTERRUPT_ACK
] = WL18XX_REG_INTERRUPT_ACK
,
101 [REG_COMMAND_MAILBOX_PTR
] = WL18XX_REG_COMMAND_MAILBOX_PTR
,
102 [REG_EVENT_MAILBOX_PTR
] = WL18XX_REG_EVENT_MAILBOX_PTR
,
103 [REG_INTERRUPT_TRIG
] = WL18XX_REG_INTERRUPT_TRIG_H
,
104 [REG_INTERRUPT_MASK
] = WL18XX_REG_INTERRUPT_MASK
,
105 [REG_PC_ON_RECOVERY
] = 0, /* TODO: where is the PC? */
106 [REG_CHIP_ID_B
] = WL18XX_REG_CHIP_ID_B
,
107 [REG_CMD_MBOX_ADDRESS
] = WL18XX_CMD_MBOX_ADDRESS
,
109 /* data access memory addresses, used with partition translation */
110 [REG_SLV_MEM_DATA
] = WL18XX_SLV_MEM_DATA
,
111 [REG_SLV_REG_DATA
] = WL18XX_SLV_REG_DATA
,
113 /* raw data access memory addresses */
114 [REG_RAW_FW_STATUS_ADDR
] = WL18XX_FW_STATUS_ADDR
,
117 /* TODO: maybe move to a new header file? */
118 #define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin"
120 static int wl18xx_identify_chip(struct wl1271
*wl
)
124 switch (wl
->chip
.id
) {
125 case CHIP_ID_185x_PG10
:
126 wl1271_debug(DEBUG_BOOT
, "chip id 0x%x (185x PG10)",
128 wl
->sr_fw_name
= WL18XX_FW_NAME
;
129 wl
->quirks
|= WLCORE_QUIRK_NO_ELP
;
131 /* TODO: need to blocksize alignment for RX/TX separately? */
134 wl1271_warning("unsupported chip id: 0x%x", wl
->chip
.id
);
143 static void wl18xx_set_clk(struct wl1271
*wl
)
146 * TODO: this is hardcoded just for DVP/EVB, fix according to
149 wl1271_write32(wl
, WL18XX_SCR_PAD2
, 0xB3);
151 wlcore_set_partition(wl
, &wl
->ptable
[PART_TOP_PRCM_ELP_SOC
]);
152 wl1271_write32(wl
, 0x00A02360, 0xD0078);
153 wl1271_write32(wl
, 0x00A0236c, 0x12);
154 wl1271_write32(wl
, 0x00A02390, 0x20118);
157 static void wl18xx_boot_soft_reset(struct wl1271
*wl
)
160 wl1271_write32(wl
, WL18XX_ENABLE
, 0x0);
162 /* disable auto calibration on start*/
163 wl1271_write32(wl
, WL18XX_SPARE_A2
, 0xffff);
166 static int wl18xx_pre_boot(struct wl1271
*wl
)
168 /* TODO: add hw_pg_ver reading */
172 /* Continue the ELP wake up sequence */
173 wl1271_write32(wl
, WL18XX_WELP_ARM_COMMAND
, WELP_ARM_COMMAND_VAL
);
176 wlcore_set_partition(wl
, &wl
->ptable
[PART_BOOT
]);
178 /* Disable interrupts */
179 wlcore_write_reg(wl
, REG_INTERRUPT_MASK
, WL1271_ACX_INTR_ALL
);
181 wl18xx_boot_soft_reset(wl
);
186 static void wl18xx_pre_upload(struct wl1271
*wl
)
190 wlcore_set_partition(wl
, &wl
->ptable
[PART_BOOT
]);
192 /* TODO: check if this is all needed */
193 wl1271_write32(wl
, WL18XX_EEPROMLESS_IND
, WL18XX_EEPROMLESS_IND
);
195 tmp
= wlcore_read_reg(wl
, REG_CHIP_ID_B
);
197 wl1271_debug(DEBUG_BOOT
, "chip id 0x%x", tmp
);
199 tmp
= wl1271_read32(wl
, WL18XX_SCR_PAD2
);
202 static void wl18xx_set_mac_and_phy(struct wl1271
*wl
)
204 struct wl18xx_mac_and_phy_params params
;
206 memset(¶ms
, 0, sizeof(params
));
208 params
.phy_standalone
= wl18xx_default_conf
.phy
.phy_standalone
;
209 params
.rdl
= wl18xx_default_conf
.phy
.rdl
;
210 params
.enable_clpc
= wl18xx_default_conf
.phy
.enable_clpc
;
211 params
.enable_tx_low_pwr_on_siso_rdl
=
212 wl18xx_default_conf
.phy
.enable_tx_low_pwr_on_siso_rdl
;
213 params
.auto_detect
= wl18xx_default_conf
.phy
.auto_detect
;
214 params
.dedicated_fem
= wl18xx_default_conf
.phy
.dedicated_fem
;
215 params
.low_band_component
= wl18xx_default_conf
.phy
.low_band_component
;
216 params
.low_band_component_type
=
217 wl18xx_default_conf
.phy
.low_band_component_type
;
218 params
.high_band_component
=
219 wl18xx_default_conf
.phy
.high_band_component
;
220 params
.high_band_component_type
=
221 wl18xx_default_conf
.phy
.high_band_component_type
;
222 params
.number_of_assembled_ant2_4
=
223 wl18xx_default_conf
.phy
.number_of_assembled_ant2_4
;
224 params
.number_of_assembled_ant5
=
225 wl18xx_default_conf
.phy
.number_of_assembled_ant5
;
226 params
.external_pa_dc2dc
= wl18xx_default_conf
.phy
.external_pa_dc2dc
;
227 params
.tcxo_ldo_voltage
= wl18xx_default_conf
.phy
.tcxo_ldo_voltage
;
228 params
.xtal_itrim_val
= wl18xx_default_conf
.phy
.xtal_itrim_val
;
229 params
.srf_state
= wl18xx_default_conf
.phy
.srf_state
;
230 params
.io_configuration
= wl18xx_default_conf
.phy
.io_configuration
;
231 params
.sdio_configuration
= wl18xx_default_conf
.phy
.sdio_configuration
;
232 params
.settings
= wl18xx_default_conf
.phy
.settings
;
233 params
.rx_profile
= wl18xx_default_conf
.phy
.rx_profile
;
234 params
.primary_clock_setting_time
=
235 wl18xx_default_conf
.phy
.primary_clock_setting_time
;
236 params
.clock_valid_on_wake_up
=
237 wl18xx_default_conf
.phy
.clock_valid_on_wake_up
;
238 params
.secondary_clock_setting_time
=
239 wl18xx_default_conf
.phy
.secondary_clock_setting_time
;
241 /* TODO: hardcoded for now */
242 params
.board_type
= BOARD_TYPE_DVP_EVB_18XX
;
244 wlcore_set_partition(wl
, &wl
->ptable
[PART_PHY_INIT
]);
245 wl1271_write(wl
, WL18XX_PHY_INIT_MEM_ADDR
, (u8
*)¶ms
,
246 sizeof(params
), false);
249 static void wl18xx_enable_interrupts(struct wl1271
*wl
)
251 wlcore_write_reg(wl
, REG_INTERRUPT_MASK
, WL1271_ACX_ALL_EVENTS_VECTOR
);
253 wlcore_enable_interrupts(wl
);
254 wlcore_write_reg(wl
, REG_INTERRUPT_MASK
,
255 WL1271_ACX_INTR_ALL
& ~(WL1271_INTR_MASK
));
258 static int wl18xx_boot(struct wl1271
*wl
)
262 ret
= wl18xx_pre_boot(wl
);
266 ret
= wlcore_boot_upload_nvs(wl
);
270 wl18xx_pre_upload(wl
);
272 ret
= wlcore_boot_upload_firmware(wl
);
276 wl18xx_set_mac_and_phy(wl
);
278 ret
= wlcore_boot_run_firmware(wl
);
282 wl18xx_enable_interrupts(wl
);
288 static void wl18xx_trigger_cmd(struct wl1271
*wl
, int cmd_box_addr
,
289 void *buf
, size_t len
)
291 struct wl18xx_priv
*priv
= wl
->priv
;
293 memcpy(priv
->cmd_buf
, buf
, len
);
294 memset(priv
->cmd_buf
+ len
, 0, WL18XX_CMD_MAX_SIZE
- len
);
296 wl1271_write(wl
, cmd_box_addr
, priv
->cmd_buf
, WL18XX_CMD_MAX_SIZE
,
300 static void wl18xx_ack_event(struct wl1271
*wl
)
302 wlcore_write_reg(wl
, REG_INTERRUPT_TRIG
, WL18XX_INTR_TRIG_EVENT_ACK
);
305 static struct wlcore_ops wl18xx_ops
= {
306 .identify_chip
= wl18xx_identify_chip
,
308 .trigger_cmd
= wl18xx_trigger_cmd
,
309 .ack_event
= wl18xx_ack_event
,
312 int __devinit
wl18xx_probe(struct platform_device
*pdev
)
315 struct ieee80211_hw
*hw
;
317 hw
= wlcore_alloc_hw(0);
319 wl1271_error("can't allocate hw");
324 wl
->ops
= &wl18xx_ops
;
325 wl
->ptable
= wl18xx_ptable
;
326 wl
->rtable
= wl18xx_rtable
;
328 return wlcore_probe(wl
, pdev
);
331 static const struct platform_device_id wl18xx_id_table
[] __devinitconst
= {
333 { } /* Terminating Entry */
335 MODULE_DEVICE_TABLE(platform
, wl18xx_id_table
);
337 static struct platform_driver wl18xx_driver
= {
338 .probe
= wl18xx_probe
,
339 .remove
= __devexit_p(wlcore_remove
),
340 .id_table
= wl18xx_id_table
,
342 .name
= "wl18xx_driver",
343 .owner
= THIS_MODULE
,
347 static int __init
wl18xx_init(void)
349 return platform_driver_register(&wl18xx_driver
);
351 module_init(wl18xx_init
);
353 static void __exit
wl18xx_exit(void)
355 platform_driver_unregister(&wl18xx_driver
);
357 module_exit(wl18xx_exit
);
359 MODULE_LICENSE("GPL v2");
360 MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
361 MODULE_FIRMWARE(WL18XX_FW_NAME
);