[Macchiato] Fan control

Matt Sealey neko at bakuhatsu.net
Mon Apr 9 18:57:21 BST 2018


Just to correct myself after snooping around some; you can change that
pin to GPIO and set the "Blink" function to get a PWM effect - the
mvebu driver in Linux does have this which is pretty difficult to
read, but the binding says:

~~~~
In order to use the GPIO lines in PWM mode, some additional optional
properties are required.

- compatible: Must contain "marvell,armada-370-gpio"

- reg: an additional register set is needed, for the GPIO Blink
  Counter on/off registers.

- reg-names: Must contain an entry "pwm" corresponding to the
  additional register range needed for PWM operation.

- #pwm-cells: Should be two. The first cell is the GPIO line number. The
  second cell is the period in nanoseconds.
~~~~

I'm not sure about that armada-370 bit, but it'll get in your way per
the driver /drivers/gpio/gpio-mvebu.c:

if (!of_device_is_compatible(mvchip->chip.of_node,
    "marvell,armada-370-gpio"))
return 0;

.. and there's something to set the registers up. I can't imagine it's
any different but I haven't found an example of an Armada 370 config
with PWM set up yet..
....

You'll need to futz with pinctrl to make sure that pin is set to GPIO
if it isn't by default. It is in UEFI:

 gMarvellTokenSpaceGuid.PcdChip1MppSel4|{ 0x7, 0x7, 0x8, 0x8, 0x0,
0x0, 0x0, 0x0, 0x0 /* <--- this is MPP48 set to GPIO */, 0x0 }

There's no DT entry for this pin range in the cp110 DT file so it
should stay as such..

The thermal sensor is in the DT, at the bottom:

/arch/arm64/boot/dts/marvell/armada-ap806.dtsi

And this is the driver:

/drivers/thermal/armada_thermal.c

.. the biggest question I have now is what's the least hacky way to
link thermal and pwm subsystems together? :)

Ta,
Matt

On 6 April 2018 at 17:39, Matt Sealey <neko at bakuhatsu.net> wrote:
> You understood correctly.
>
> Having software toggle a GPIO fast enough to effect PWM would be highly
> processor intensive. that would heat the package meaning running the fan
> faster, you’ll make yourself a nice feedback loop!
>
> There is a thermal diode and a way to calibrate and use it since U-Boot
> reports it and I can see the temp in sysfs (it reacts to the diode on my
> case fan speeding up the case fan and moving more air...).
>
> I’m just not sure you could do a lot with it just being a GPIO, the only
> clock-like function for that pin is the MDIO clock for one of the Ethernet
> PHYs - if you can prove that same clock is not exported, though, you could
> use clock management to do what you want. MDIO clocks aren’t fast though, so
> it may be the difference between full off, very slow rpm (if the fan
> supports that range of duty cycle) and full on, not a nice
> temperature-controlled swing.
>
> Ta,
> Matt
>
> On Fri, Apr 6, 2018 at 16:26 Duncan <dguthrie at posteo.net> wrote:
>>
>> Hello Matt,
>>
>> Matt Sealey:
>> > According to the schematics it's on CP0_MPP48 which I do not believe
>> > is touched by anything in EFI or Linux. There's no I2C to require,
>> > just I assume an ability to multiplex something useful on that pin -
>> > pinctrl driver remarks that it's got GPIO and I'm fairly sure the 8040
>> > doesn't even have any PWM functionality (unless you count the TDM, you
>> > could play with the frame sync..)
>> >
>> >
>> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pinctrl/mvebu/pinctrl-armada-cp110.c#n466
>> >
>>
>> So as far as I understand from your reply, the PWM pin is wired up, but
>> that the SoC itself doesn't have native PWM functionality built-in?
>>
>> > But what you've got here is a potential for a GPIO - on or off - or
>> > the MDIO clock for 'XG' which probably means losing an ethernet port
>> > since you can't clock the PHY and use it for PWM.
>> >
>> > You could write a driver that took a rapid firing timer event to
>> > change the GPIO state, but that'd probably consume enough power and
>> > reduce idle state residency enough to only make matters worse.
>>
>> Let's say I wrote a driver that could interface with this pin, and I was
>> able to control fan speed this way (if this is possible). Does the
>> Armada 8040 SoC have any infrastructure for detecting its temperature,
>> and the temperature of other parts of the board?
>>
>> My main goal here is to allow me to vary the fan speed of the
>> side-blowers in the case I'm using; it seems like a terrible waste of
>> power to have them on at full speed, given the board is going to be idle
>> quite a lot, and even at high load probably doesn't need the fans at
>> full speed.
>>
>> All the best, and apologies in advance if I misunderstood your reply,
>> Duncan
>>
>> _______________________________________________
>> Macchiato mailing list
>> Macchiato at lists.einval.com
>> https://lists.einval.com/cgi-bin/mailman/listinfo/macchiato



More information about the Macchiato mailing list