Lines Matching full:wilc

35  * For CMD_SINGLE_READ and CMD_INTERNAL_READ, WILC may insert one or
57 static int wilc_spi_reset(struct wilc *wilc);
58 static int wilc_spi_configure_bus_protocol(struct wilc *wilc);
59 static int wilc_validate_chipid(struct wilc *wilc);
163 static int wilc_parse_gpios(struct wilc *wilc) in wilc_parse_gpios() argument
165 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_parse_gpios()
166 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_parse_gpios()
188 static void wilc_wlan_power(struct wilc *wilc, bool on) in wilc_wlan_power() argument
190 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_wlan_power()
211 struct wilc *wilc; in wilc_bus_probe() local
218 ret = wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi); in wilc_bus_probe()
222 spi_set_drvdata(spi, wilc); in wilc_bus_probe()
223 wilc->dev = &spi->dev; in wilc_bus_probe()
224 wilc->bus_data = spi_priv; in wilc_bus_probe()
225 wilc->dev_irq_num = spi->irq; in wilc_bus_probe()
227 ret = wilc_parse_gpios(wilc); in wilc_bus_probe()
231 wilc->rtc_clk = devm_clk_get_optional_enabled(&spi->dev, "rtc"); in wilc_bus_probe()
232 if (IS_ERR(wilc->rtc_clk)) { in wilc_bus_probe()
233 ret = PTR_ERR(wilc->rtc_clk); in wilc_bus_probe()
242 wilc_wlan_power(wilc, true); in wilc_bus_probe()
244 ret = wilc_spi_configure_bus_protocol(wilc); in wilc_bus_probe()
248 ret = wilc_validate_chipid(wilc); in wilc_bus_probe()
252 ret = wilc_load_mac_from_nv(wilc); in wilc_bus_probe()
258 wilc_wlan_power(wilc, false); in wilc_bus_probe()
259 vif = wilc_netdev_ifc_init(wilc, "wlan%d", WILC_STATION_MODE, in wilc_bus_probe()
268 wilc_wlan_power(wilc, false); in wilc_bus_probe()
270 wilc_netdev_cleanup(wilc); in wilc_bus_probe()
278 struct wilc *wilc = spi_get_drvdata(spi); in wilc_bus_remove() local
279 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_bus_remove()
281 wilc_netdev_cleanup(wilc); in wilc_bus_remove()
310 static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len) in wilc_spi_tx() argument
312 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_tx()
352 static int wilc_spi_rx(struct wilc *wilc, u8 *rb, u32 rlen) in wilc_spi_rx() argument
354 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_rx()
393 static int wilc_spi_tx_rx(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen) in wilc_spi_tx_rx() argument
395 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_tx_rx()
428 static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz) in spi_data_write() argument
430 struct spi_device *spi = to_spi_device(wilc->dev); in spi_data_write()
431 struct wilc_spi *spi_priv = wilc->bus_data; in spi_data_write()
459 if (wilc_spi_tx(wilc, &cmd, 1)) { in spi_data_write()
469 if (wilc_spi_tx(wilc, &b[ix], nbytes)) { in spi_data_write()
483 if (wilc_spi_tx(wilc, crc, 2)) { in spi_data_write()
510 static int wilc_spi_single_read(struct wilc *wilc, u8 cmd, u32 adr, void *b, in wilc_spi_single_read() argument
513 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_single_read()
514 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_single_read()
557 if (wilc_spi_tx_rx(wilc, wb, rb, cmd_len + resp_len)) { in wilc_spi_single_read()
605 static int wilc_spi_write_cmd(struct wilc *wilc, u8 cmd, u32 adr, u32 data, in wilc_spi_write_cmd() argument
608 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_write_cmd()
609 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_write_cmd()
654 if (wilc_spi_tx_rx(wilc, wb, rb, cmd_len + resp_len)) { in wilc_spi_write_cmd()
680 static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz) in wilc_spi_dma_rw() argument
682 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_dma_rw()
683 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_dma_rw()
731 if (wilc_spi_tx_rx(wilc, wb, rb, cmd_len + resp_len)) { in wilc_spi_dma_rw()
764 if (wilc_spi_rx(wilc, &rsp, 1)) { in wilc_spi_dma_rw()
776 if (wilc_spi_rx(wilc, &b[ix], nbytes)) { in wilc_spi_dma_rw()
786 if (wilc_spi_rx(wilc, crc, 2)) { in wilc_spi_dma_rw()
807 static int wilc_spi_special_cmd(struct wilc *wilc, u8 cmd) in wilc_spi_special_cmd() argument
809 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_special_cmd()
810 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_special_cmd()
840 if (wilc_spi_tx_rx(wilc, wb, rb, cmd_len + resp_len)) { in wilc_spi_special_cmd()
862 static void wilc_spi_reset_cmd_sequence(struct wilc *wl, u8 attempt, u32 addr) in wilc_spi_reset_cmd_sequence()
875 static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) in wilc_spi_read_reg() argument
877 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_read_reg()
890 result = wilc_spi_single_read(wilc, cmd, addr, data, clockless); in wilc_spi_read_reg()
901 wilc_spi_reset_cmd_sequence(wilc, i, addr); in wilc_spi_read_reg()
907 static int wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) in wilc_spi_read() argument
909 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_read()
917 result = wilc_spi_dma_rw(wilc, CMD_DMA_EXT_READ, addr, in wilc_spi_read()
924 wilc_spi_reset_cmd_sequence(wilc, i, addr); in wilc_spi_read()
930 static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat) in spi_internal_write() argument
932 struct spi_device *spi = to_spi_device(wilc->dev); in spi_internal_write()
937 result = wilc_spi_write_cmd(wilc, CMD_INTERNAL_WRITE, adr, in spi_internal_write()
943 wilc_spi_reset_cmd_sequence(wilc, i, adr); in spi_internal_write()
949 static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data) in spi_internal_read() argument
951 struct spi_device *spi = to_spi_device(wilc->dev); in spi_internal_read()
952 struct wilc_spi *spi_priv = wilc->bus_data; in spi_internal_read()
957 result = wilc_spi_single_read(wilc, CMD_INTERNAL_READ, adr, in spi_internal_read()
966 wilc_spi_reset_cmd_sequence(wilc, i, adr); in spi_internal_read()
978 static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) in wilc_spi_write_reg() argument
980 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_write_reg()
993 result = wilc_spi_write_cmd(wilc, cmd, addr, data, clockless); in wilc_spi_write_reg()
1002 wilc_spi_reset_cmd_sequence(wilc, i, addr); in wilc_spi_write_reg()
1007 static int spi_data_rsp(struct wilc *wilc, u8 cmd) in spi_data_rsp() argument
1009 struct spi_device *spi = to_spi_device(wilc->dev); in spi_data_rsp()
1025 result = wilc_spi_rx(wilc, rsp, sizeof(rsp)); in spi_data_rsp()
1053 static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) in wilc_spi_write() argument
1055 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_write()
1066 result = wilc_spi_dma_rw(wilc, CMD_DMA_EXT_WRITE, addr, in wilc_spi_write()
1071 wilc_spi_reset_cmd_sequence(wilc, i, addr); in wilc_spi_write()
1078 result = spi_data_write(wilc, buf, size); in wilc_spi_write()
1081 wilc_spi_reset_cmd_sequence(wilc, i, addr); in wilc_spi_write()
1088 result = spi_data_rsp(wilc, CMD_DMA_EXT_WRITE); in wilc_spi_write()
1091 wilc_spi_reset_cmd_sequence(wilc, i, addr); in wilc_spi_write()
1105 static int wilc_spi_reset(struct wilc *wilc) in wilc_spi_reset() argument
1107 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_reset()
1108 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_reset()
1111 result = wilc_spi_special_cmd(wilc, CMD_RESET); in wilc_spi_reset()
1118 static bool wilc_spi_is_init(struct wilc *wilc) in wilc_spi_is_init() argument
1120 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_is_init()
1125 static int wilc_spi_deinit(struct wilc *wilc) in wilc_spi_deinit() argument
1127 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_deinit()
1130 wilc_wlan_power(wilc, false); in wilc_spi_deinit()
1134 static int wilc_spi_init(struct wilc *wilc, bool resume) in wilc_spi_init() argument
1136 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_init()
1141 if (wilc_validate_chipid(wilc) == 0) in wilc_spi_init()
1145 wilc_wlan_power(wilc, true); in wilc_spi_init()
1147 ret = wilc_spi_configure_bus_protocol(wilc); in wilc_spi_init()
1149 wilc_wlan_power(wilc, false); in wilc_spi_init()
1158 static int wilc_spi_configure_bus_protocol(struct wilc *wilc) in wilc_spi_configure_bus_protocol() argument
1160 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_configure_bus_protocol()
1161 struct wilc_spi *spi_priv = wilc->bus_data; in wilc_spi_configure_bus_protocol()
1174 ret = spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, &reg); in wilc_spi_configure_bus_protocol()
1199 ret = spi_internal_write(wilc, WILC_SPI_PROTOCOL_OFFSET, reg); in wilc_spi_configure_bus_protocol()
1202 "[wilc spi %d]: Failed internal write reg\n", in wilc_spi_configure_bus_protocol()
1211 spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, &reg); in wilc_spi_configure_bus_protocol()
1218 static int wilc_validate_chipid(struct wilc *wilc) in wilc_validate_chipid() argument
1220 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_validate_chipid()
1227 ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid); in wilc_validate_chipid()
1239 static int wilc_spi_read_size(struct wilc *wilc, u32 *size) in wilc_spi_read_size() argument
1243 ret = spi_internal_read(wilc, in wilc_spi_read_size()
1250 static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) in wilc_spi_read_int() argument
1252 return spi_internal_read(wilc, WILC_SPI_INT_STATUS - WILC_SPI_REG_BASE, in wilc_spi_read_int()
1256 static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) in wilc_spi_clear_int_ext() argument
1263 ret = spi_internal_write(wilc, in wilc_spi_clear_int_ext()
1269 ret = spi_internal_read(wilc, in wilc_spi_clear_int_ext()
1280 static int wilc_spi_sync_ext(struct wilc *wilc, int nint) in wilc_spi_sync_ext() argument
1282 struct spi_device *spi = to_spi_device(wilc->dev); in wilc_spi_sync_ext()
1294 ret = wilc_spi_read_reg(wilc, WILC_PIN_MUX_0, &reg); in wilc_spi_sync_ext()
1301 ret = wilc_spi_write_reg(wilc, WILC_PIN_MUX_0, reg); in wilc_spi_sync_ext()
1311 ret = wilc_spi_read_reg(wilc, WILC_INTR_ENABLE, &reg); in wilc_spi_sync_ext()
1321 ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg); in wilc_spi_sync_ext()
1328 ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, &reg); in wilc_spi_sync_ext()
1338 ret = wilc_spi_write_reg(wilc, WILC_INTR2_ENABLE, reg); in wilc_spi_sync_ext()