| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * wl12xx SDIO routines |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 6 | | - * published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 9 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 11 | | - * General Public License for more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License |
|---|
| 14 | | - * along with this program; if not, write to the Free Software |
|---|
| 15 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
|---|
| 16 | | - * 02110-1301 USA |
|---|
| 17 | 4 | * |
|---|
| 18 | 5 | * Copyright (C) 2005 Texas Instruments Incorporated |
|---|
| 19 | 6 | * Copyright (C) 2008 Google Inc |
|---|
| .. | .. |
|---|
| 28 | 15 | #include <linux/wl12xx.h> |
|---|
| 29 | 16 | #include <linux/irq.h> |
|---|
| 30 | 17 | #include <linux/pm_runtime.h> |
|---|
| 31 | | -#include <linux/gpio.h> |
|---|
| 18 | +#include <linux/of.h> |
|---|
| 19 | +#include <linux/of_irq.h> |
|---|
| 32 | 20 | |
|---|
| 33 | 21 | #include "wl1251.h" |
|---|
| 34 | | - |
|---|
| 35 | | -#ifndef SDIO_VENDOR_ID_TI |
|---|
| 36 | | -#define SDIO_VENDOR_ID_TI 0x104c |
|---|
| 37 | | -#endif |
|---|
| 38 | | - |
|---|
| 39 | | -#ifndef SDIO_DEVICE_ID_TI_WL1251 |
|---|
| 40 | | -#define SDIO_DEVICE_ID_TI_WL1251 0x9066 |
|---|
| 41 | | -#endif |
|---|
| 42 | 22 | |
|---|
| 43 | 23 | struct wl1251_sdio { |
|---|
| 44 | 24 | struct sdio_func *func; |
|---|
| .. | .. |
|---|
| 62 | 42 | } |
|---|
| 63 | 43 | |
|---|
| 64 | 44 | static const struct sdio_device_id wl1251_devices[] = { |
|---|
| 65 | | - { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1251) }, |
|---|
| 45 | + { SDIO_DEVICE(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251) }, |
|---|
| 66 | 46 | {} |
|---|
| 67 | 47 | }; |
|---|
| 68 | 48 | MODULE_DEVICE_TABLE(sdio, wl1251_devices); |
|---|
| .. | .. |
|---|
| 178 | 158 | int ret; |
|---|
| 179 | 159 | |
|---|
| 180 | 160 | if (enable) { |
|---|
| 181 | | - /* |
|---|
| 182 | | - * Power is controlled by runtime PM, but we still call board |
|---|
| 183 | | - * callback in case it wants to do any additional setup, |
|---|
| 184 | | - * for example enabling clock buffer for the module. |
|---|
| 185 | | - */ |
|---|
| 186 | | - if (gpio_is_valid(wl->power_gpio)) |
|---|
| 187 | | - gpio_set_value(wl->power_gpio, true); |
|---|
| 188 | | - |
|---|
| 189 | | - |
|---|
| 190 | 161 | ret = pm_runtime_get_sync(&func->dev); |
|---|
| 191 | 162 | if (ret < 0) { |
|---|
| 192 | 163 | pm_runtime_put_sync(&func->dev); |
|---|
| .. | .. |
|---|
| 204 | 175 | ret = pm_runtime_put_sync(&func->dev); |
|---|
| 205 | 176 | if (ret < 0) |
|---|
| 206 | 177 | goto out; |
|---|
| 207 | | - |
|---|
| 208 | | - if (gpio_is_valid(wl->power_gpio)) |
|---|
| 209 | | - gpio_set_value(wl->power_gpio, false); |
|---|
| 210 | 178 | } |
|---|
| 211 | 179 | |
|---|
| 212 | 180 | out: |
|---|
| .. | .. |
|---|
| 230 | 198 | struct ieee80211_hw *hw; |
|---|
| 231 | 199 | struct wl1251_sdio *wl_sdio; |
|---|
| 232 | 200 | const struct wl1251_platform_data *wl1251_board_data; |
|---|
| 201 | + struct device_node *np = func->dev.of_node; |
|---|
| 233 | 202 | |
|---|
| 234 | 203 | hw = wl1251_alloc_hw(); |
|---|
| 235 | 204 | if (IS_ERR(hw)) |
|---|
| .. | .. |
|---|
| 258 | 227 | |
|---|
| 259 | 228 | wl1251_board_data = wl1251_get_platform_data(); |
|---|
| 260 | 229 | if (!IS_ERR(wl1251_board_data)) { |
|---|
| 261 | | - wl->power_gpio = wl1251_board_data->power_gpio; |
|---|
| 262 | 230 | wl->irq = wl1251_board_data->irq; |
|---|
| 263 | 231 | wl->use_eeprom = wl1251_board_data->use_eeprom; |
|---|
| 264 | | - } |
|---|
| 265 | | - |
|---|
| 266 | | - if (gpio_is_valid(wl->power_gpio)) { |
|---|
| 267 | | - ret = devm_gpio_request(&func->dev, wl->power_gpio, |
|---|
| 268 | | - "wl1251 power"); |
|---|
| 269 | | - if (ret) { |
|---|
| 270 | | - wl1251_error("Failed to request gpio: %d\n", ret); |
|---|
| 232 | + } else if (np) { |
|---|
| 233 | + wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); |
|---|
| 234 | + wl->irq = of_irq_get(np, 0); |
|---|
| 235 | + if (wl->irq == -EPROBE_DEFER) { |
|---|
| 236 | + ret = -EPROBE_DEFER; |
|---|
| 271 | 237 | goto disable; |
|---|
| 272 | 238 | } |
|---|
| 273 | 239 | } |
|---|