CV1800B: pinctrl: Initial support.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
9493444405
commit
6dd9fe0d8b
|
@ -20,16 +20,30 @@
|
|||
stdout-path = "serial0:115200n8";
|
||||
};
|
||||
|
||||
memory@0 {
|
||||
memory@80000000 {
|
||||
device_type = "memory";
|
||||
reg = <0x0 0x80000000 0x0 0x03F40000>; /* Offset 0, size: 63.25MB */
|
||||
};
|
||||
};
|
||||
|
||||
&pinctrl {
|
||||
uart0_pins: uart0 {
|
||||
pinmux = <PINMUX(UART0_TX, UART0_TX)>, <PINMUX(UART0_RX, UART0_RX)>;
|
||||
};
|
||||
|
||||
i2c1_pins: i2c1 {
|
||||
pinmux = <PINMUX(PAD_MIPIRX0N, IIC1_SCL)>, <PINMUX(PAD_MIPIRX1P, IIC1_SDA)>;
|
||||
};
|
||||
};
|
||||
|
||||
&uart0 {
|
||||
pinctrl-0 = <&uart0_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c0 {
|
||||
&i2c1 {
|
||||
pinctrl-0 = <&i2c1_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -75,24 +75,16 @@
|
|||
interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
|
||||
};
|
||||
|
||||
pinctrl: pinctrl@03000000 {
|
||||
pinctrl: pinctrl@03001000 {
|
||||
compatible = "cvitek,cv1800b-pinctrl";
|
||||
reg = <0x0 0x03000000 0x0 0x00001000>;
|
||||
|
||||
uart0_pins: uart0_pins {
|
||||
pinmux = <PINMUX(UART0_TX, UART0_TX)>, <PINMUX(UART0_RX, UART0_RX)>;
|
||||
};
|
||||
|
||||
i2c0_pins: i2c0_pins {
|
||||
pinmux = <PINMUX(IIC0_SCL, IIC0_SCL)>, <PINMUX(IIC0_SDA, IIC0_SDA)>;
|
||||
};
|
||||
reg = <0x0 0x03001000 0x0 0x00001000>;
|
||||
pins = <75>;
|
||||
};
|
||||
|
||||
uart0: serial@04140000 {
|
||||
compatible = "cvitek,cv1800b-uart", "snps,dw-apb-uart";
|
||||
reg = <0x0 0x04140000 0x0 0x1000>;
|
||||
interrupts = <44 IRQ_TYPE_LEVEL_HIGH>;
|
||||
pinctrl-0 = <&uart0_pins>;
|
||||
clocks = <&apb_clk>;
|
||||
reg-shift = <2>;
|
||||
reg-io-width = <4>;
|
||||
|
@ -146,5 +138,13 @@
|
|||
clocks = <&apb_clk>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
i2c1: i2c@04010000 {
|
||||
compatible = "cvitek,cv1800b-i2c", "snps,designware-i2c";
|
||||
reg = <0x0 0x04010000 0x0 0x1000>;
|
||||
interrupts = <50 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clocks = <&apb_clk>;
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
#include <linux/bitfield.h>
|
||||
#include <linux/bitops.h>
|
||||
|
||||
#define CV1800B_PC_CTRL_MAX 128
|
||||
/* The maximum address space PINMUX can have is 4kB */
|
||||
#define CV1800B_PC_CTRL_MAX 1024
|
||||
|
||||
#define CV1800B_PC_FUNC GENMASK(3, 0)
|
||||
#define CV1800B_PC_FUNC GENMASK(2, 0)
|
||||
|
||||
struct cv1800b_pinmux{
|
||||
u32 ctrl[CV1800B_PC_CTRL_MAX];
|
||||
|
@ -26,17 +27,42 @@ struct cv1800b_pinmux{
|
|||
|
||||
struct cv1800b_pc_priv {
|
||||
struct cv1800b_pinmux __iomem *pinmux;
|
||||
uint32_t num_pins;
|
||||
u32 num_pins;
|
||||
};
|
||||
|
||||
int cv1800b_pc_get_pins_count(struct udevice *dev)
|
||||
static int cv1800b_pc_get_pins_count(struct udevice *dev)
|
||||
{
|
||||
struct cv1800b_pc_priv *priv = dev_get_priv(dev);
|
||||
|
||||
debug("%s: pin count: %d", __func__, priv->num_pins);
|
||||
|
||||
return priv->num_pins;
|
||||
}
|
||||
|
||||
static int cv1800b_pc_pinmux_set(struct udevice *dev, u32 pinmux_group)
|
||||
{
|
||||
struct cv1800b_pc_priv *priv = dev_get_priv(dev);
|
||||
|
||||
u8 pin = pinmux_group & 0xFFU;
|
||||
u8 func = (pinmux_group >> 8U) & 0xFFU;
|
||||
|
||||
priv->pinmux->ctrl[pin] = (priv->pinmux->ctrl[pin] & ~(CV1800B_PC_FUNC)) | func;
|
||||
|
||||
debug("%s: pin %d, func: %d\n", __func__, pin, func);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pinconf_param cv1800b_pinconf_params[] = {
|
||||
{ "input-enable", PIN_CONFIG_INPUT_ENABLE, 1 },
|
||||
};
|
||||
|
||||
static const struct pinctrl_ops cv1800b_pc_pinctrl_ops = {
|
||||
.get_pins_count = cv1800b_pc_get_pins_count,
|
||||
.pinmux_property_set = cv1800b_pc_pinmux_set,
|
||||
.pinconf_num_params = ARRAY_SIZE(cv1800b_pinconf_params),
|
||||
.pinconf_params = cv1800b_pinconf_params,
|
||||
.set_state = pinctrl_generic_set_state,
|
||||
};
|
||||
|
||||
static int cv1800b_pc_probe(struct udevice *dev)
|
||||
|
|
Loading…
Reference in New Issue
Block a user