[PATCH 1/2] spi: bcm2835: add spi-bcm2835aux driver for the auxiliar spi1 and spi2

Martin Sperl kernel at martin.sperl.org
Tue Jul 28 03:48:39 PDT 2015


On 28.07.2015 08:18, Martin Sperl wrote:
> Hi Stephen!
> But the bigger question you have not answered is: “where should such an
> auxiliar driver go in the kernel tree?” i.e. which directory?
One thing: could the "module" be a regulator?

So drivers/regulators/bcm2835-aux-regulator.c

The devicetree would look something like this:

regulators {
     bcm2835aux_reg {
         compatible = "bcrm,bcrm-2835-aux-enable";
         reg = <0x7e215004 0x4>; /* the AUX enable register */

         bcm2835aux_uart1: {
             regulator-name = "bcm2835_aux_uart1";
             reg = <0>; /* bit 0 in enable register */
         };
         bcm2835aux_spi1: {
             regulator-name = "bcm2835_aux_spi1";
             reg = <1>; /* bit 1 in enable register */
         };
         bcm2835aux_spi2: {
             regulator-name = "bcm2835_aux_spi2";
             reg = <2>; /* bit 2 in enable register */
         };
     }
};

uart1: uart1 at 7e215040 {
compatible = "brcm,bcm2835-aux-uart";
     reg = <0x7e215040 0x40>;
     ...
     vcc = <&bcm2835aux_uart1>
};

spi1: spi1 at 7e215080 {
compatible = "brcm,bcm2835-aux-spi";
     reg = <0x7e215080 0x40>;
     ...
     vcc = <&bcm2835aux_spi1>
};

spi2: spi2 at 7e2150C0 {
compatible = "brcm,bcm2835-aux-spi";
     reg = <0x7e2150C0 0x40>;
     ...
     vcc = <&bcm2835aux_spi2>
};

And the necessary driver-side code for bcm2835aux_spi and
bcm2835aux_uart would be along those lines:

probe:
   /* get the "power-supply" */
   bs->power = devm_regulator_get(dev, "vcc");
   if ((PTR_ERR(priv->power) == -EPROBE_DEFER)
     return -EPROBE_DEFER
   /* enable the power-supply */
   regulator_enable(bs->power);

remove:
   regulator_disable(bs->power);

Would that look like an acceptable solution?

Thanks,
	Martin




More information about the linux-rpi-kernel mailing list