Compare commits

...

2 Commits

Author SHA1 Message Date
8b381fa4f0
Board: Milk-V Duo: Enable pinctrl by default.
Signed-off-by: Yilin Sun <imi415@imi.moe>
2023-09-07 00:55:56 +08:00
6dd9fe0d8b
CV1800B: pinctrl: Initial support.
Signed-off-by: Yilin Sun <imi415@imi.moe>
2023-09-07 00:40:18 +08:00
5 changed files with 60 additions and 18 deletions

View File

@ -20,16 +20,30 @@
stdout-path = "serial0:115200n8"; stdout-path = "serial0:115200n8";
}; };
memory@0 { memory@80000000 {
device_type = "memory"; device_type = "memory";
reg = <0x0 0x80000000 0x0 0x03F40000>; /* Offset 0, size: 63.25MB */ 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 { &uart0 {
pinctrl-0 = <&uart0_pins>;
pinctrl-names = "default";
status = "okay"; status = "okay";
}; };
&i2c0 { &i2c1 {
pinctrl-0 = <&i2c1_pins>;
pinctrl-names = "default";
status = "okay"; status = "okay";
}; };

View File

@ -75,24 +75,16 @@
interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>; interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
}; };
pinctrl: pinctrl@03000000 { pinctrl: pinctrl@03001000 {
compatible = "cvitek,cv1800b-pinctrl"; compatible = "cvitek,cv1800b-pinctrl";
reg = <0x0 0x03000000 0x0 0x00001000>; reg = <0x0 0x03001000 0x0 0x00001000>;
pins = <75>;
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)>;
};
}; };
uart0: serial@04140000 { uart0: serial@04140000 {
compatible = "cvitek,cv1800b-uart", "snps,dw-apb-uart"; compatible = "cvitek,cv1800b-uart", "snps,dw-apb-uart";
reg = <0x0 0x04140000 0x0 0x1000>; reg = <0x0 0x04140000 0x0 0x1000>;
interrupts = <44 IRQ_TYPE_LEVEL_HIGH>; interrupts = <44 IRQ_TYPE_LEVEL_HIGH>;
pinctrl-0 = <&uart0_pins>;
clocks = <&apb_clk>; clocks = <&apb_clk>;
reg-shift = <2>; reg-shift = <2>;
reg-io-width = <4>; reg-io-width = <4>;
@ -146,5 +138,13 @@
clocks = <&apb_clk>; clocks = <&apb_clk>;
status = "disabled"; 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";
};
}; };
}; };

View File

@ -23,6 +23,7 @@ config BOARD_SPECIFIC_OPTIONS
imply RISCV_TIMER if RISCV_SMODE imply RISCV_TIMER if RISCV_SMODE
imply CMD_CPU imply CMD_CPU
imply SUPPORT_OF_CONTROL imply SUPPORT_OF_CONTROL
imply PINCTRL_CV1800B
imply OF_CONTROL imply OF_CONTROL
imply OF_REAL imply OF_REAL
endif endif

View File

@ -5,7 +5,6 @@ CONFIG_NR_DRAM_BANKS=1
CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000
CONFIG_DEFAULT_DEVICE_TREE="cv1800b-milkv-duo" CONFIG_DEFAULT_DEVICE_TREE="cv1800b-milkv-duo"
CONFIG_SYS_PROMPT="Milk-V => "
CONFIG_SYS_LOAD_ADDR=0x80200000 CONFIG_SYS_LOAD_ADDR=0x80200000
CONFIG_TARGET_CV1800B_MILKV_DUO=y CONFIG_TARGET_CV1800B_MILKV_DUO=y
CONFIG_ARCH_RV64I=y CONFIG_ARCH_RV64I=y
@ -25,6 +24,7 @@ CONFIG_LOG=y
CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_CPUINFO=y
CONFIG_DISPLAY_BOARDINFO=y CONFIG_DISPLAY_BOARDINFO=y
CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_SYS_PROMPT="Milk-V => "
CONFIG_SYS_CBSIZE=256 CONFIG_SYS_CBSIZE=256
CONFIG_SYS_PBSIZE=276 CONFIG_SYS_PBSIZE=276
CONFIG_CMD_CONFIG=y CONFIG_CMD_CONFIG=y
@ -66,6 +66,7 @@ CONFIG_SYSCON=y
# CONFIG_INPUT is not set # CONFIG_INPUT is not set
# CONFIG_DM_MMC is not set # CONFIG_DM_MMC is not set
# CONFIG_MTD is not set # CONFIG_MTD is not set
CONFIG_PINCTRL=y
# CONFIG_POWER is not set # CONFIG_POWER is not set
CONFIG_SYS_NS16550=y CONFIG_SYS_NS16550=y
CONFIG_AES=y CONFIG_AES=y

View File

@ -16,9 +16,10 @@
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/bitops.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{ struct cv1800b_pinmux{
u32 ctrl[CV1800B_PC_CTRL_MAX]; u32 ctrl[CV1800B_PC_CTRL_MAX];
@ -26,17 +27,42 @@ struct cv1800b_pinmux{
struct cv1800b_pc_priv { struct cv1800b_pc_priv {
struct cv1800b_pinmux __iomem *pinmux; 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); struct cv1800b_pc_priv *priv = dev_get_priv(dev);
debug("%s: pin count: %d", __func__, priv->num_pins);
return 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 = { static const struct pinctrl_ops cv1800b_pc_pinctrl_ops = {
.get_pins_count = cv1800b_pc_get_pins_count, .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) static int cv1800b_pc_probe(struct udevice *dev)