OSDN Git Service

96f438d4b026f397f306feb2bd64b11d20602192
[uclinux-h8/linux.git] / arch / x86 / platform / intel-mid / device_libs / platform_bcm43xx.c
1 /*
2  * platform_bcm43xx.c: bcm43xx platform data initialization file
3  *
4  * (C) Copyright 2016 Intel Corporation
5  * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; version 2
10  * of the License.
11  */
12
13 #include <linux/gpio/machine.h>
14 #include <linux/platform_device.h>
15 #include <linux/regulator/machine.h>
16 #include <linux/regulator/fixed.h>
17 #include <linux/sfi.h>
18
19 #include <asm/intel-mid.h>
20
21 #define WLAN_SFI_GPIO_IRQ_NAME          "WLAN-interrupt"
22 #define WLAN_SFI_GPIO_ENABLE_NAME       "WLAN-enable"
23
24 #define WLAN_DEV_NAME                   "0000:00:01.3"
25
26 static struct regulator_consumer_supply bcm43xx_vmmc_supply = {
27         .dev_name               = WLAN_DEV_NAME,
28         .supply                 = "vmmc",
29 };
30
31 static struct regulator_init_data bcm43xx_vmmc_data = {
32         .constraints = {
33                 .valid_ops_mask         = REGULATOR_CHANGE_STATUS,
34         },
35         .num_consumer_supplies  = 1,
36         .consumer_supplies      = &bcm43xx_vmmc_supply,
37 };
38
39 static struct fixed_voltage_config bcm43xx_vmmc = {
40         .supply_name            = "bcm43xx-vmmc-regulator",
41         /*
42          * Announce 2.0V here to be compatible with SDIO specification. The
43          * real voltage and signaling are still 1.8V.
44          */
45         .microvolts             = 2000000,              /* 1.8V */
46         .startup_delay          = 250 * 1000,           /* 250ms */
47         .enable_high            = 1,                    /* active high */
48         .enabled_at_boot        = 0,                    /* disabled at boot */
49         .init_data              = &bcm43xx_vmmc_data,
50 };
51
52 static struct platform_device bcm43xx_vmmc_regulator = {
53         .name           = "reg-fixed-voltage",
54         .id             = PLATFORM_DEVID_AUTO,
55         .dev = {
56                 .platform_data  = &bcm43xx_vmmc,
57         },
58 };
59
60 static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = {
61         .dev_id = "reg-fixed-voltage.0",
62         .table  = {
63                 GPIO_LOOKUP("0000:00:0c.0", -1, NULL, GPIO_ACTIVE_LOW),
64                 {}
65         },
66 };
67
68 static int __init bcm43xx_regulator_register(void)
69 {
70         struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table;
71         struct gpiod_lookup *lookup = table->table;
72         int ret;
73
74         lookup[0].chip_hwnum = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME);
75         gpiod_add_lookup_table(table);
76
77         ret = platform_device_register(&bcm43xx_vmmc_regulator);
78         if (ret) {
79                 pr_err("%s: vmmc regulator register failed\n", __func__);
80                 return ret;
81         }
82
83         return 0;
84 }
85
86 static void __init *bcm43xx_platform_data(void *info)
87 {
88         int ret;
89
90         ret = bcm43xx_regulator_register();
91         if (ret)
92                 return NULL;
93
94         pr_info("Using generic wifi platform data\n");
95
96         /* For now it's empty */
97         return NULL;
98 }
99
100 static const struct devs_id bcm43xx_clk_vmmc_dev_id __initconst = {
101         .name                   = "bcm43xx_clk_vmmc",
102         .type                   = SFI_DEV_TYPE_SD,
103         .get_platform_data      = &bcm43xx_platform_data,
104 };
105
106 sfi_device(bcm43xx_clk_vmmc_dev_id);