Skip to content

Commit

Permalink
airoha: sync MFD implementation with upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel committed Aug 30, 2024
1 parent 7384fe3 commit 4bfb0ee
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 54 deletions.
6 changes: 1 addition & 5 deletions target/linux/airoha/dts/en7581-evb-emmc.dts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
};
};

&pio {
&pinctrl {
gpio-ranges = <&pio 0 13 47>;

mdio_pins: mdio-pins {
Expand Down Expand Up @@ -188,10 +188,6 @@
status = "okay";
};

&pwm {
status = "okay";
};

&pcie0 {
pinctrl-names = "default";
pinctrl-0 = <&pcie0_rst_pins>;
Expand Down
6 changes: 1 addition & 5 deletions target/linux/airoha/dts/en7581-evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
pinctrl-0 = <&pwm_gpio18_idx10_pins>;
lan4_green {
label = "pon:green";
pwms = <&pwm 10 4000000 0>;
pwms = <&pio 10 4000000 0>;
max-brightness = <255>;
};
};
Expand Down Expand Up @@ -237,10 +237,6 @@
status = "okay";
};

&pwm {
status = "okay";
};

&pcie0 {
pinctrl-names = "default";
pinctrl-0 = <&pcie0_rst_pins>;
Expand Down
21 changes: 6 additions & 15 deletions target/linux/airoha/dts/en7581.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -274,29 +274,20 @@
#thermal-sensor-cells = <0>;
};

mfd@1fbf0200 {
pio: mfd@1fbf0200 {
compatible = "airoha,en7581-gpio-mfd";
reg = <0x0 0x1fbf0200 0x0 0xc0>;

interrupt-parent = <&gic>;
interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;

pio: pinctrl {
compatible = "airoha,en7581-pinctrl";
gpio-controller;
#gpio-cells = <2>;

gpio-controller;
#gpio-cells = <2>;

interrupt-controller;
#interrupt-cells = <2>;
};

pwm: pwm {
compatible = "airoha,en7581-pwm";
interrupt-controller;
#interrupt-cells = <2>;

#pwm-cells = <3>;
status = "disabled";
};
#pwm-cells = <3>;
};

i2cclock: i2cclock@0 {
Expand Down
14 changes: 4 additions & 10 deletions target/linux/airoha/files/drivers/mfd/airoha-en7581-mfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ static struct resource airoha_mfd_pinctrl_intr[] = {
static const struct mfd_cell airoha_mfd_devs[] = {
{
.name = "pinctrl-airoha",
.of_compatible = "airoha,en7581-pinctrl",
.resources = airoha_mfd_pinctrl_intr,
.num_resources = ARRAY_SIZE(airoha_mfd_pinctrl_intr),
},
{
.name = "airoha-pwm",
.of_compatible = "airoha,en7581-pwm",
},
};

static int airoha_mfd_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct airoha_mfd *mfd;
int irq, ret;
int irq;

mfd = devm_kzalloc(dev, sizeof(*mfd), GFP_KERNEL);
if (!mfd)
Expand All @@ -50,13 +48,9 @@ static int airoha_mfd_probe(struct platform_device *pdev)
airoha_mfd_pinctrl_intr[0].start = irq;
airoha_mfd_pinctrl_intr[0].end = irq;

ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO,
airoha_mfd_devs, ARRAY_SIZE(airoha_mfd_devs),
NULL, 0, NULL);
if (ret)
return ret;

return 0;
return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO,
airoha_mfd_devs, ARRAY_SIZE(airoha_mfd_devs),
NULL, 0, NULL);
}

static const struct of_device_id airoha_mfd_of_match[] = {
Expand Down
11 changes: 3 additions & 8 deletions target/linux/airoha/files/drivers/pinctrl/pinctrl-airoha.c
Original file line number Diff line number Diff line change
Expand Up @@ -2888,6 +2888,8 @@ static int airoha_pinctrl_probe(struct platform_device *pdev)
struct regmap *map;
int err, i;

/* Assign parent MFD of_node to dev */
dev->of_node = of_node_get(dev->parent->of_node);
mfd = dev_get_drvdata(dev->parent);

pinctrl = devm_kzalloc(dev, sizeof(*pinctrl), GFP_KERNEL);
Expand Down Expand Up @@ -2947,17 +2949,10 @@ static int airoha_pinctrl_probe(struct platform_device *pdev)
return airoha_pinctrl_add_gpiochip(pinctrl, pdev);
}

static const struct of_device_id of_airoha_pinctrl_match[] = {
{ .compatible = "airoha,en7581-pinctrl" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_airoha_pinctrl_match);

static struct platform_driver airoha_pinctrl_driver = {
.probe = airoha_pinctrl_probe,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = of_airoha_pinctrl_match,
.name = "pinctrl-airoha",
},
};
module_platform_driver(airoha_pinctrl_driver);
Expand Down
21 changes: 10 additions & 11 deletions target/linux/airoha/files/drivers/pwm/pwm-airoha.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,19 +392,25 @@ static const struct pwm_ops airoha_pwm_ops = {

static int airoha_pwm_probe(struct platform_device *pdev)
{
struct airoha_mfd *mfd = dev_get_drvdata(pdev->dev.parent);
struct device *dev = &pdev->dev;
struct airoha_mfd *mfd;
struct airoha_pwm *pc;

pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);

/* Assign parent MFD of_node to dev */
dev->of_node = of_node_get(dev->parent->of_node);
mfd = dev_get_drvdata(dev->parent);

pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
if (!pc)
return -ENOMEM;

pc->sgpio_cfg = mfd->base + REG_SGPIO_CFG;
pc->flash_cfg = mfd->base + REG_FLASH_CFG;
pc->cycle_cfg = mfd->base + REG_CYCLE_CFG;

pc->np = pdev->dev.of_node;
pc->chip.dev = &pdev->dev;
pc->np = dev->of_node;
pc->chip.dev = dev;
pc->chip.ops = &airoha_pwm_ops;
pc->chip.base = -1;
pc->chip.npwm = PWM_NUM_GPIO + PWM_NUM_SIPO;
Expand All @@ -425,16 +431,9 @@ static int airoha_pwm_remove(struct platform_device *pdev)
return 0;
}

static const struct of_device_id airoha_pwm_of_match[] = {
{ .compatible = "airoha,en7581-pwm" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, airoha_pwm_of_match);

static struct platform_driver airoha_pwm_driver = {
.driver = {
.name = "airoha-pwm",
.of_match_table = airoha_pwm_of_match,
},
.probe = airoha_pwm_probe,
.remove = airoha_pwm_remove,
Expand Down

0 comments on commit 4bfb0ee

Please sign in to comment.