CV1800B: Pinmux: Added get pincount.

Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
Yilin Sun 2023-09-04 16:26:05 +08:00
parent 31581c4539
commit 05e9c815f3
Signed by: imi415
GPG Key ID: DB982239424FF8AC
2 changed files with 29 additions and 5 deletions

View File

@ -197,7 +197,7 @@ config PINCTRL_AT91
config PINCTRL_CV1800B
bool "CVITEK CV1800B pinctrl driver"
depends_on DM
depends on DM
help
This option is to enable the CV1800B pinctrl driver.

View File

@ -16,22 +16,46 @@
#include <linux/bitfield.h>
#include <linux/bitops.h>
#define CV1800B_PC_CTRL_MAX 128
#define CV1800B_PC_FUNC GENMASK(3, 0)
struct cv1800b_pinmux{
u32 ctrl[75];
u32 ctrl[CV1800B_PC_CTRL_MAX];
};
struct cv1800b_pc_priv {
struct cv1800b_pinmux __iomem *pinmux;
uint32_t num_pins;
};
int cv1800b_pc_get_pins_count(struct udevice *dev)
{
struct cv1800b_pc_priv *priv = dev_get_priv(dev);
return priv->num_pins;
}
static const struct pinctrl_ops cv1800b_pc_pinctrl_ops = {
.get_pins_count = cv1800b_pc_get_pins_count,
};
static int cv1800b_pc_probe(struct udevice *dev)
{
struct cv1800b_pc_priv *priv = dev_get_priv(dev);
priv->pinmux = dev_read_addr_ptr(dev);
if(!priv->pinmux)
return -EINVAL;
if(dev_read_u32(dev, "pins", &priv->num_pins) < 0)
return -EINVAL;
debug("%s: pinctrl@%p, %d pins\n", __func__, priv->pinmux, priv->num_pins);
return 0;
}
static const struct device_id cv1800b_pc_ids[] = {
static const struct udevice_id cv1800b_pc_ids[] = {
{ .compatible = "cvitek,cv1800b-pinctrl" },
{ }
};
@ -42,5 +66,5 @@ U_BOOT_DRIVER(pinctrl_cv1800b) = {
.of_match = cv1800b_pc_ids,
.probe = cv1800b_pc_probe,
.priv_auto = sizeof(struct cv1800b_pc_priv),
.ops = &cv1800b_pc_ops,
}
.ops = &cv1800b_pc_pinctrl_ops,
};