| 18 | |
| 19 | #ifdef RT_USING_OFW |
| 20 | static rt_err_t ofw_pin_ctrl_confs_apply(struct rt_ofw_node *np, int index) |
| 21 | { |
| 22 | rt_err_t err = -RT_EEMPTY; |
| 23 | rt_phandle phandle; |
| 24 | const fdt32_t *cell; |
| 25 | struct rt_ofw_prop *prop; |
| 26 | char pinctrl_n_name[sizeof("pinctrl-0")]; |
| 27 | |
| 28 | rt_sprintf(pinctrl_n_name, "pinctrl-%d", index); |
| 29 | index = 0; |
| 30 | |
| 31 | rt_ofw_foreach_prop_u32(np, pinctrl_n_name, prop, cell, phandle) |
| 32 | { |
| 33 | struct rt_device_pin *pinctrl = RT_NULL; |
| 34 | struct rt_ofw_node *conf_np, *pinctrl_np; |
| 35 | |
| 36 | conf_np = pinctrl_np = rt_ofw_find_node_by_phandle(phandle); |
| 37 | |
| 38 | if (!conf_np) |
| 39 | { |
| 40 | err = -RT_EIO; |
| 41 | |
| 42 | break; |
| 43 | } |
| 44 | /* |
| 45 | * We always assume the phandle in pinctrl-N is the pinctrl-device |
| 46 | * node's child node. If not, we need a better way to find it: |
| 47 | * |
| 48 | * / { |
| 49 | * serial@4600 { |
| 50 | * device_type = "serial"; |
| 51 | * reg = <0x4600 0x100>; |
| 52 | * clock-frequency = <0>; |
| 53 | * pinctrl-names = "default"; |
| 54 | * pinctrl-0 = <&uart_pin>; |
| 55 | * }; |
| 56 | * |
| 57 | * i2c@4700 { |
| 58 | * reg = <0x4700 0x100>; |
| 59 | * pinctrl-names = "default"; |
| 60 | * pinctrl-0 = <&i2c_pin_scl, &i2c_pin_sda>; |
| 61 | * }; |
| 62 | * |
| 63 | * pinctrl: pinctrl { |
| 64 | * |
| 65 | * uart_pin { |
| 66 | * multi,pins = |
| 67 | * <0 PD0 1 &uart_rx_pull_up>, |
| 68 | * <0 PD1 1 &uart_tx_pull_up>; |
| 69 | * }; |
| 70 | * |
| 71 | * i2c_pin_scl { |
| 72 | * single,pins = <0 PB1>; |
| 73 | * pull = <&i2c_pull_none_smt>; |
| 74 | * function = <1>; |
| 75 | * }; |
| 76 | * |
| 77 | * i2c_pin_sda { |
no test coverage detected