dts pinctl rk3288
原文链接: dts pinctl rk3288
wireless-bluetooth {
compatible = "bluetooth-platdata";
//wifi-bt-power-toggle;
uart_rts_gpios = <&gpio4 GPIO_C3 GPIO_ACTIVE_LOW>;
pinctrl-names = "default","rts_gpio";
pinctrl-0 = <&uart0_rts>;
pinctrl-1 = <&uart0_rts_gpio>;
BT,power_gpio = <&gpio4 GPIO_D3 GPIO_ACTIVE_HIGH>;
BT,reset_gpio = <&gpio4 GPIO_D5 GPIO_ACTIVE_HIGH>;
BT,wake_gpio = <&gpio4 GPIO_D2 GPIO_ACTIVE_HIGH>;
BT,wake_host_irq = <&gpio4 GPIO_D7 GPIO_ACTIVE_LOW>;
status = "okay";
};
&pinctrl {
wireless-bluetooth {
uart0_rts_gpio: uart0-rts-gpios {
rockchip,pins = <3 11 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
};
rfkill-bt.c
static int bluetooth_platdata_parse_dt(struct device *dev,
struct rfkill_rk_platform_data *data)
{
struct device_node *node = dev->of_node;
int gpio;
enum of_gpio_flags flags;
if (!node)
return -ENODEV;
memset(data, 0, sizeof(*data));
if (of_find_property(node, "wifi-bt-power-toggle", NULL)) {
data->power_toggle = true;
LOG("%s: get property wifi-bt-power-toggle.\n", __func__);
} else {
data->power_toggle = false;
}
gpio = of_get_named_gpio_flags(node, "uart_rts_gpios", 0, &flags);
if (gpio_is_valid(gpio)) {
data->rts_gpio.io = gpio;
data->rts_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
LOG("%s: get property: uart_rts_gpios = %d.\n", __func__, gpio);
data->pinctrl = devm_pinctrl_get(dev);
if (!IS_ERR(data->pinctrl)) {
data->rts_gpio.default_state = pinctrl_lookup_state(data->pinctrl, "default");
data->rts_gpio.gpio_state = pinctrl_lookup_state(data->pinctrl, "rts_gpio");
} else {
data->pinctrl = NULL;
LOG("%s: dts does't define the uart rts iomux.\n", __func__);
return -EINVAL;
}
} else {
data->pinctrl = NULL;
data->rts_gpio.io = -EINVAL;
LOG("%s: uart_rts_gpios is no-in-use.\n", __func__);
}
gpio = of_get_named_gpio_flags(node, "BT,power_gpio", 0, &flags);
if (gpio_is_valid(gpio)){
data->poweron_gpio.io = gpio;
data->poweron_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
LOG("%s: get property: BT,power_gpio = %d.\n", __func__, gpio);
} else data->poweron_gpio.io = -1;
gpio = of_get_named_gpio_flags(node, "BT,reset_gpio", 0, &flags);
if (gpio_is_valid(gpio)){
data->reset_gpio.io = gpio;
data->reset_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
LOG("%s: get property: BT,reset_gpio = %d.\n", __func__, gpio);
} else data->reset_gpio.io = -1;
gpio = of_get_named_gpio_flags(node, "BT,wake_gpio", 0, &flags);
if (gpio_is_valid(gpio)){
data->wake_gpio.io = gpio;
data->wake_gpio.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
LOG("%s: get property: BT,wake_gpio = %d.\n", __func__, gpio);
} else data->wake_gpio.io = -1;
gpio = of_get_named_gpio_flags(node, "BT,wake_host_irq", 0, &flags);
if (gpio_is_valid(gpio)) {
data->wake_host_irq.gpio.io = gpio;
data->wake_host_irq.gpio.enable = flags;
LOG("%s: get property: BT,wake_host_irq = %d.\n", __func__, gpio);
} else data->wake_host_irq.gpio.io = -1;
data->ext_clk = devm_clk_get(dev, "ext_clock");
if (IS_ERR(data->ext_clk)) {
LOG("%s: clk_get failed!!!.\n", __func__);
} else {
clk_prepare_enable(data->ext_clk);
}
return 0;
}
static struct of_device_id bt_platdata_of_match[] = {
{ .compatible = "bluetooth-platdata" },
{ }
};