Aspeed PWM driver support
Included :
Aspeed PWM controller driver
Aspeed PWM device driver
Todo:
Aspeed FAn tacho driver
PATCH 1/3 drivers: hwmon: Support for Aspeed PWM controller driver
Support to give all the common information required by all the PWM channels.
--- .../bindings/hwmon/aspeed_pwm_controller.txt | 33 +++ drivers/hwmon/Kconfig | 5 + drivers/hwmon/Makefile | 2 +- drivers/hwmon/aspeed_pwm.h | 159 ++++++++++++++ drivers/hwmon/aspeed_pwm_controller.c | 237 +++++++++++++++++++++ 5 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt create mode 100644 drivers/hwmon/aspeed_pwm.h create mode 100644 drivers/hwmon/aspeed_pwm_controller.c
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +33 -0
@@ -0,0 +1,33 @@ +Aspeed PWM controller driver + +Required properties: +- reg : address and length of the register set for the device. +- #address-cells : should be 1. +- #size-cells : should be 1. +- compatible : should be "aspeed-pwm-controller". +- clock_enable : option to enable PWM and fan tach clock. should be 1. +- clock_source : option for clock source selection. 0 indicates 24MHz clock + and 1 indicates MCLK. +- typem_pwm_clock : This array contains 3 values. The first value indicates + the type M PWM clock division L bit. The second value indicates type M PWM + clock divison H bit. The third value indicates type M PWM period bit. + +Optional properties: +- typen_pwm_clock : This array contains 3 values. The first value indicates + the type N PWM clock division L bit. The second value indicates type N PWM + clock division H bit. The third value indicates type N PWM period bit. +- typeo_pwm_clock : This array contains 3 values. The first value indicates + the type O PWM clock division L bit. The second value indicates type O PWM + clock divison H bit. The third value indicates type O PWM period bit. + +Examples: + +pwm_controller { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-controller"; + clock_enable = /bits/ 8 <0x01>; + clock_source = /bits/ 8 <0x00>; + typem_pwm_clock = <5 0 95>; +};
drivers/hwmon/Kconfig +5 -0
@@ -1803,6 +1803,11 @@ config SENSORS_WM8350 This driver can also be built as a module. If so, the module will be called wm8350-hwmon. +config ASPEED_PWM_CONTROLLER + tristate "Aspeed PWM controller" + help + This driver provides support for ASPEED PWM controller. + config SENSORS_ULTRA45 tristate "Sun Ultra45 PIC16F747" depends on SPARC64
drivers/hwmon/Makefile +1 -1
@@ -164,7 +164,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o - +obj-$(CONFIG_ASPEED_PWM_CONTROLLER) += aspeed_pwm_controller.o obj-$(CONFIG_PMBUS) += pmbus/ ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
drivers/hwmon/aspeed_pwm.h new file +159 -0
159 lines not on this page · raw message
drivers/hwmon/aspeed_pwm_controller.c new file +237 -0
237 lines not on this page · raw message
--
2.8.0.rc3.226.g39d4020
PATCH 2/3 drivers: hwmon: Drive support for ASPEED PWM device
In reply to Jaghathiswari Rankappagounder Natarajan--- .../bindings/hwmon/aspeed_pwm_device.txt | 32 ++ drivers/hwmon/Kconfig | 5 + drivers/hwmon/Makefile | 2 +- drivers/hwmon/aspeed_pwm_dev.c | 480 +++++++++++++++++++++ 4 files changed, 518 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed_pwm_device.txt create mode 100644 drivers/hwmon/aspeed_pwm_dev.c
Documentation/devicetree/bindings/hwmon/aspeed_pwm_device.txt new file +32 -0
@@ -0,0 +1,32 @@ +Aspeed PWM device driver + +Required properties: +- reg : address and length of the register set for the device. +- #address-cells : should be 1. +- #size-cells : should be 1. +- compatible : should be "aspeed-pwm-dev". +- pinctrl-names: A pinctrl state names "default" must be defined. +- pinctrl-0 : Phandle referencing pin configuration of the aspeed pwm channel. +- pwm_channel_enable : Indicates the PWM channel to enable. Values 0 through 7 + indicate PWM channels A through H respectively. +- pwm_type : Indicates the clock type for the PWM channel. value 0 is type M + PWM clock. value 1 is type N PWM clock. value 2 is type O PWM clock. Value + 0 (type M ) is default. If any other type is preferred, say type N, then + typen_pwm_clock array of values have to be specified in pwm-controller node. +- rising : Indicates the PWM channel rising point bit. +- falling : Indicates the PWM channel falling point bit. + +Examples: + +pwm0 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default>; + pwm_channel_enable = /bits/ 8 <0x00>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; +};
drivers/hwmon/Kconfig +5 -0
@@ -1815,6 +1815,11 @@ config SENSORS_ULTRA45 This driver provides support for the Ultra45 workstation environmental sensors. +config ASPEED_PWM_DEVICE + tristate "Aspeed PWM device" + help + This driver provides support for ASPEED PWM device. + if ACPI comment "ACPI drivers"
drivers/hwmon/Makefile +1 -1
@@ -166,6 +166,6 @@ obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o obj-$(CONFIG_ASPEED_PWM_CONTROLLER) += aspeed_pwm_controller.o obj-$(CONFIG_PMBUS) += pmbus/ - +obj-$(CONFIG_ASPEED_PWM_DEV) += aspeed_pwm_dev.o ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
drivers/hwmon/aspeed_pwm_dev.c new file +480 -0
480 lines not on this page · raw message
--
2.8.0.rc3.226.g39d4020
PATCH 3/3 devicetree: Add support in Zaius for PWM controller and four PWM outputs(fans)
In reply to Jaghathiswari Rankappagounder Natarajan--- arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +63 -0
@@ -83,6 +83,69 @@ gpios = <&gpio ASPEED_GPIO(H, 7) GPIO_ACTIVE_LOW>; }; }; + + pwm_controller { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-controller"; + clock_enable = /bits/ 8 <0x01>; + clock_source = /bits/ 8 <0x00>; + typem_pwm_clock = <5 0 95>; + }; + + pwm0 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default>; + pwm_channel_enable = /bits/ 8 <0x00>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + + pwm1 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm1_default>; + pwm_channel_enable = /bits/ 8 <0x01>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + + pwm2 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm2_default>; + pwm_channel_enable = /bits/ 8 <0x02>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + + pwm3 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm3_default>; + pwm_channel_enable = /bits/ 8 <0x03>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + }; &uart5 {
--
2.8.0.rc3.226.g39d4020
This cover letter doesn't have the normal formatting. Are you using --cover-letter with 'git send-email'?
Quoted 12 lines · Jaghathiswari Rankappagounder Natarajan
Included :
Aspeed PWM controller driver
Aspeed PWM device driverTodo:
Aspeed FAn tacho driver_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc
Quoted 2 lines · Rick Altherr
This cover letter doesn't have the normal formatting. Are you using --cover-letter with 'git send-email'?
Some more words would be good too. It would be nice to have a description of the relationships between the drivers, the state of the code, the amount of testing done, and any hardware oddities that hamper the implementation for example.
Andrew
Quoted 19 lines
Quoted 4 lines · Jaghathiswari Rankappagounder Natarajan
Included :
Aspeed PWM controller driver
Aspeed PWM device driverQuoted 8 lines
Todo:
Aspeed FAn tacho driver_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc
Re: [PATCH linux v1 1/3] drivers: hwmon: Support for Aspeed PWM controller driver
In reply to Jaghathiswari Rankappagounder NatarajanQuoted 4 lines · Jaghathiswari Rankappagounder Natarajan
Support to give all the common information required by all the PWM channels.
This description doesn't help me understand what problem you are solving. From Section 2, Describe Your Changes, of
https://www.kernel.org/doc/Documentation/SubmittingPatches: "Convince the reviewer that there is a problem worth fixing and that it makes sense for them to read past the first paragraph." I suggest reading that whole section.
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt
Quoted 21 lines
--- .../bindings/hwmon/aspeed_pwm_controller.txt | 33 +++ drivers/hwmon/Kconfig | 5 + drivers/hwmon/Makefile | 2 +- drivers/hwmon/aspeed_pwm.h | 159 ++++++++++++++ drivers/hwmon/aspeed_pwm_controller.c | 237 +++++++++++++++++++++ 5 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed_pwm_ controller.txt create mode 100644 drivers/hwmon/aspeed_pwm.h create mode 100644 drivers/hwmon/aspeed_pwm_controller.cDocumentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +0
-0
Per
https://www.kernel.org/doc/Documentation/devicetree/bindings/submitting-patches.txt,
the binding documentation updates should be a separate patch.
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt line 1
Quoted 3 lines
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +1
-0@@ -0,0 +1,33 @@ +Aspeed PWM controller driver
You're implying that there is only one PWM controller they have _and_ _will_ ever use. Including AST2400/2500 in the description puts some reasonable bounds and directs people to the correct SoCs that will have documentation in their datasheets.
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt line 7
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +6
-0+ +Required properties: +- reg : address and length of the register set for the device. +- #address-cells : should be 1. +- #size-cells : should be 1. +- compatible : should be "aspeed-pwm-controller".
I thought the format was "<manufacturer>,<chip>-<device>" so "aspeed,ast2500-pwm"
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +2
-0+- clock_enable : option to enable PWM and fan tach clock. should be 1. +- clock_source : option for clock source selection. 0 indicates 24MHzclock
+ and 1 indicates MCLK.
+-typem_pwm_clock: This array contains 3 values. The first value indicates
+ the type M PWM clock division L bit. The second value indicates type M PWM
+ clock divison H bit. The third value indicates type M PWM period bit.
I have no idea what any of this means. What is type M clock division? How do I determine the L, H, and period bits?
Quoted 484 lines
Documentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +3
-0+ +Optional properties: +- typen_pwm_clock : This array contains 3 values. The first valueindicates
+ the type N PWM clock division L bit. The second value indicates type N PWM
+ clock division H bit. The third value indicates type N PWM period bit. +-typeo_pwm_clock: This array contains 3 values. The first value indicates
+ the type O PWM clock division L bit. The second value indicates type O PWMDocumentation/devicetree/bindings/hwmon/aspeed_pwm_controller.txt new file +13
-0+ clock divison H bit. The third value indicates type O PWM period bit. + +Examples: + +pwm_controller { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-controller"; + clock_enable = /bits/ 8 <0x01>; + clock_source = /bits/ 8 <0x00>; + typem_pwm_clock = <5 0 95>; +};drivers/hwmon/Kconfig +5
-0@@ -1803,6 +1803,11 @@ config SENSORS_WM8350 This driver can also be built as a module. If so, the module will be called wm8350-hwmon. +config ASPEED_PWM_CONTROLLER + tristate "Aspeed PWM controller" + help + This driver provides support for ASPEED PWM controller. + config SENSORS_ULTRA45 tristate "Sun Ultra45 PIC16F747" depends on SPARC64drivers/hwmon/Makefile +1
-1@@ -164,7 +164,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o - +obj-$(CONFIG_ASPEED_PWM_CONTROLLER) += aspeed_pwm_controller.o obj-$(CONFIG_PMBUS) += pmbus/ ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUGdrivers/hwmon/aspeed_pwm.h new file +65
-0@@ -0,0 +1,159 @@ +/* +* Aspeed PWM header file +* * Copyright (c) 2016 Google, Inc +* +* * This program is free software; you can redistribute it and/or modify +* * it under the terms of the GNU General Public License version 2 as +* * published by the Free Software Foundation. +* +*/ + +#ifndef __ASPEED_PWM_H +#define __ASPEED_PWM_H __FILE__ + +/* AST PWM & FAN Register Definition */ +#define AST_PTCR_CTRL 0x00 +#define AST_PTCR_CLK_CTRL 0x04 +#define AST_PTCR_DUTY0_CTRL 0x08 +#define AST_PTCR_DUTY1_CTRL 0x0c +#define AST_PTCR_TYPEM_CTRL0 0x10 +#define AST_PTCR_TYPEM_CTRL1 0x14 +#define AST_PTCR_TYPEN_CTRL0 0x18 +#define AST_PTCR_TYPEN_CTRL1 0x1c +#define AST_PTCR_TACH_SOURCE 0x20 +#define AST_PTCR_TRIGGER 0x28 +#define AST_PTCR_RESULT 0x2c +#define AST_PTCR_INTR_CTRL 0x30 +#define AST_PTCR_INTR_STS 0x34 +#define AST_PTCR_TYPEM_LIMIT 0x38 +#define AST_PTCR_TYPEN_LIMIT 0x3C +#define AST_PTCR_CTRL_EXT 0x40 +#define AST_PTCR_CLK_EXT_CTRL 0x44 +#define AST_PTCR_DUTY2_CTRL 0x48 +#define AST_PTCR_DUTY3_CTRL 0x4c +#define AST_PTCR_TYPEO_CTRL0 0x50 +#define AST_PTCR_TYPEO_CTRL1 0x54 +#define AST_PTCR_TACH_SOURCE_EXT 0x60 +#define AST_PTCR_TYPEO_LIMIT 0x78 + +/* COMMON Definition */ +#define PWM_TYPE_M 0x0 +#define PWM_TYPE_N 0x1 +#define PWM_TYPE_O 0x2 + +#define PWMA 0x0 +#define PWMB 0x1 +#define PWMC 0x2 +#define PWMD 0x3 +#define PWME 0x4 +#define PWMF 0x5 +#define PWMG 0x6 +#define PWMH 0x7 + +#define DUTY_CTRL_PWM2_FALL_POINT (24) +#define DUTY_CTRL_PWM2_FALL_POINT_MASK (0xff<<24) +#define DUTY_CTRL_PWM2_RISE_POINT (16) +#define DUTY_CTRL_PWM2_RISE_POINT_MASK (0xff<<16) +#define DUTY_CTRL_PWM1_FALL_POINT (8) +#define DUTY_CTRL_PWM1_FALL_POINT_MASK (0xff<<8) +#define DUTY_CTRL_PWM1_RISE_POINT (0) +#define DUTY_CTRL_PWM1_RISE_POINT_MASK (0xff) + +/* AST_PTCR_CTRL : 0x00 - General Control Register */ +#define AST_PTCR_CTRL_SET_PWMD_TYPE (x) ((x & 0x1) << 15 | \ + (x & 0x2) << 6) +#define AST_PTCR_CTRL_GET_PWMD_TYPE (x) (((x & (0x1 << 7)) >> 6) |\
drivers/hwmon/aspeed_pwm.h new file +6
-0+ ((x & (0x1 << 15)) >> 15)) +#define AST_PTCR_CTRL_SET_PWMD_TYPE_MASK ((0x1 << 7) | (0x1 << 15)) + +#define AST_PTCR_CTRL_SET_PWMC_TYPE (x) ((x & 0x1) << 14 | \ + (x & 0x2) << 5) +#define AST_PTCR_CTRL_GET_PWMC_TYPE (x) (((x & (0x1 << 6)) >> 5) |\
drivers/hwmon/aspeed_pwm.h new file +6
-0+ ((x & (0x1 << 14)) >> 14)) +#define AST_PTCR_CTRL_SET_PWMC_TYPE_MASK ((0x1 << 6) | (0x1 << 14)) + +#define AST_PTCR_CTRL_SET_PWMB_TYPE (x) ((x & 0x1) << 13 | \ + (x & 0x2) << 4) +#define AST_PTCR_CTRL_GET_PWMB_TYPE (x) (((x & (0x1 << 5)) >> 4) |\
drivers/hwmon/aspeed_pwm.h new file +6
-0+ ((x & (0x1 << 13)) >> 13)) +#define AST_PTCR_CTRL_SET_PWMB_TYPE_MASK ((0x1 << 5) | (0x1 << 13)) + +#define AST_PTCR_CTRL_SET_PWMA_TYPE (x) ((x & 0x1) << 12 | \ + (x & 0x2) << 3) +#define AST_PTCR_CTRL_GET_PWMA_TYPE (x) (((x & (0x1 << 4)) >> 3) |\
drivers/hwmon/aspeed_pwm.h new file +36
-0+ ((x & (0x1 << 12)) >> 12)) +#define AST_PTCR_CTRL_SET_PWMA_TYPE_MASK ((0x1 << 4) | (0x1 << 12)) + +#define AST_PTCR_CTRL_PWMD (11) +#define AST_PTCR_CTRL_PWMD_EN (0x1 << 11) +#define AST_PTCR_CTRL_PWMC (10) +#define AST_PTCR_CTRL_PWMC_EN (0x1 << 10) +#define AST_PTCR_CTRL_PWMB (9) +#define AST_PTCR_CTRL_PWMB_EN (0x1 << 9) +#define AST_PTCR_CTRL_PWMA (8) +#define AST_PTCR_CTRL_PWMA_EN (0x1 << 8) + +/*0:24Mhz, 1:MCLK */ +#define AST_PTCR_CTRL_CLK_SRC 0x2 +#define AST_PTCR_CTRL_CLK_EN 0x1 + +/* AST_PTCR_CLK_CTRL : 0x04 - Clock Control Register */ +/* TYPE N */ +#define AST_PTCR_CLK_CTRL_TYPEN_UNIT (24) +#define AST_PTCR_CLK_CTRL_TYPEN_UNIT_MASK (0xff << 24) +#define AST_PTCR_CLK_CTRL_TYPEN_H (20) +#define AST_PTCR_CLK_CTRL_TYPEN_H_MASK (0xf << 20) +#define AST_PTCR_CLK_CTRL_TYPEN_L (16) +#define AST_PTCR_CLK_CTRL_TYPEN_L_MASK (0xf << 16) +/* TYPE M */ +#define AST_PTCR_CLK_CTRL_TYPEM_UNIT (8) +#define AST_PTCR_CLK_CTRL_TYPEM_UNIT_MASK (0xff << 8) +#define AST_PTCR_CLK_CTRL_TYPEM_H (4) +#define AST_PTCR_CLK_CTRL_TYPEM_H_MASK (0xf << 4) +#define AST_PTCR_CLK_CTRL_TYPEM_L (0) +#define AST_PTCR_CLK_CTRL_TYPEM_L_MASK (0xf) + +/* AST_PTCR_CTRL_EXT : 0x40 - General Control Extension #1 Register */ +#define AST_PTCR_CTRL_SET_PWMH_TYPE (x) ((x & 0x1) << 15 | \ + (x & 0x2) << 6) +#define AST_PTCR_CTRL_GET_PWMH_TYPE (x) (((x & (0x1 << 7)) >> 6) |\
drivers/hwmon/aspeed_pwm.h new file +6
-0+ ((x & (0x1 << 15)) >> 15)) +#define AST_PTCR_CTRL_SET_PWMH_TYPE_MASK ((0x1 << 7) | (0x1 << 15)) + +#define AST_PTCR_CTRL_SET_PWMG_TYPE (x) ((x & 0x1) << 14 | \ + (x & 0x2) << 5) +#define AST_PTCR_CTRL_GET_PWMG_TYPE (x) (((x & (0x1 << 6)) >> 5) |\
drivers/hwmon/aspeed_pwm.h new file +6
-0+ ((x & (0x1 << 14)) >> 14)) +#define AST_PTCR_CTRL_SET_PWMG_TYPE_MASK ((0x1 << 6) | (0x1 << 14)) + +#define AST_PTCR_CTRL_SET_PWMF_TYPE (x) ((x & 0x1) << 13 | \ + (x & 0x2) << 4) +#define AST_PTCR_CTRL_GET_PWMF_TYPE (x) (((x & (0x1 << 5)) >> 4) |\
drivers/hwmon/aspeed_pwm.h new file +6
-0+ ((x & (0x1 << 13)) >> 13)) +#define AST_PTCR_CTRL_SET_PWMF_TYPE_MASK ((0x1 << 5) | (0x1 << 13)) + +#define AST_PTCR_CTRL_SET_PWME_TYPE (x) ((x & 0x1) << 12 | \ + (x & 0x2) << 3) +#define AST_PTCR_CTRL_GET_PWME_TYPE (x) (((x & (0x1 << 4)) >> 3) |\
drivers/hwmon/aspeed_pwm.h new file +22
-0+ ((x & (0x1 << 12)) >> 12)) +#define AST_PTCR_CTRL_SET_PWME_TYPE_MASK ((0x1 << 4) | (0x1 << 12)) + +#define AST_PTCR_CTRL_PWMH (11) +#define AST_PTCR_CTRL_PWMH_EN (0x1 << 11) +#define AST_PTCR_CTRL_PWMG (10) +#define AST_PTCR_CTRL_PWMG_EN (0x1 << 10) +#define AST_PTCR_CTRL_PWMF (9) +#define AST_PTCR_CTRL_PWMF_EN (0x1 << 9) +#define AST_PTCR_CTRL_PWME (8) +#define AST_PTCR_CTRL_PWME_EN (0x1 << 8) + +/* AST_PTCR_CLK_EXT_CTRL : 0x44 - Clock Control Extension #1 Register */ +/* TYPE O */ +#define AST_PTCR_CLK_CTRL_TYPEO_UNIT (8) +#define AST_PTCR_CLK_CTRL_TYPEO_UNIT_MASK (0xff << 8) +#define AST_PTCR_CLK_CTRL_TYPEO_H (4) +#define AST_PTCR_CLK_CTRL_TYPEO_H_MASK (0xf << 4) +#define AST_PTCR_CLK_CTRL_TYPEO_L (0) +#define AST_PTCR_CLK_CTRL_TYPEO_L_MASK (0xf) + +#endif /* __ASPEED_PWM_H */ drivers/hwmon/aspeed_pwm_controller.c new file +25
-0@@ -0,0 +1,237 @@ +/* +* Aspeed PWM controller driver +* * Copyright (c) 2016 Google, Inc +* +* * This program is free software; you can redistribute it and/or modify +* * it under the terms of the GNU General Public License version 2 as +* * published by the Free Software Foundation. +* +*/ + +#include <linux/platform_device.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of_platform.h> +#include <linux/of_device.h> +#include <linux/io.h> + +#include "aspeed_pwm.h" + +struct ast_pwm_controller_data { +void __iomem *base; +}; + +static inline void +ast_pwm_controller_write(struct ast_pwm_controller_data *priv, u32 val,u32 reg)
drivers/hwmon/aspeed_pwm_controller.c new file +61
-0+{ +writel (val, priv->base + reg); +} + +static inline u32 +ast_pwm_controller_read (struct ast_pwm_controller_data *priv,u32 reg) +{ +u32 val =readl (priv->base + reg); +return val; +} + +static void +ast_set_pwm_clock_enable (struct ast_pwm_controller_data *priv,u8 val) +{ +if (val) { +ast_pwm_controller_write (priv, +ast_pwm_controller_read (priv,AST_PTCR_CTRL ) | +AST_PTCR_CTRL_CLK_EN ,AST_PTCR_CTRL ); + }else { +ast_pwm_controller_write (priv, +ast_pwm_controller_read (priv,AST_PTCR_CTRL ) & + ~AST_PTCR_CTRL_CLK_EN ,AST_PTCR_CTRL ); + } +} + +static void +ast_set_pwm_clock_source (struct ast_pwm_controller_data *priv,u8 val) +{ +if (val) { +ast_pwm_controller_write (priv, +ast_pwm_controller_read (priv,AST_PTCR_CTRL ) | +AST_PTCR_CTRL_CLK_SRC ,AST_PTCR_CTRL ); + }else { +ast_pwm_controller_write (priv, +ast_pwm_controller_read (priv,AST_PTCR_CTRL ) & + ~AST_PTCR_CTRL_CLK_SRC ,AST_PTCR_CTRL ); + } +} + +static void +ast_set_pwm_clock_division_h (struct ast_pwm_controller_data *priv, +u8 pwm_type,u8 div_high) +{ +switch (pwm_type) { +case PWM_TYPE_M : +ast_pwm_controller_write (priv, + (ast_pwm_controller_read (priv,AST_PTCR_CLK_CTRL ) & + ~AST_PTCR_CLK_CTRL_TYPEM_H_MASK ) | + (div_high <<AST_PTCR_CLK_CTRL_TYPEM_H ), +AST_PTCR_CLK_CTRL ); +break ; +case PWM_TYPE_N : +ast_pwm_controller_write (priv, + (ast_pwm_controller_read (priv,AST_PTCR_CLK_CTRL ) & + ~AST_PTCR_CLK_CTRL_TYPEN_H_MASK ) | + (div_high <<AST_PTCR_CLK_CTRL_TYPEN_H ), +AST_PTCR_CLK_CTRL ); +break ; +case PWM_TYPE_O : + ast_pwm_controller_write(priv, + (ast_pwm_controller_read(priv,
AST_PTCR_CLK_EXT_CTRL) &drivers/hwmon/aspeed_pwm_controller.c new file +29
-0+ ~AST_PTCR_CLK_CTRL_TYPEO_H_MASK) | + (div_high <<AST_PTCR_CLK_CTRL_TYPEO_H ), + AST_PTCR_CLK_EXT_CTRL); +break ; + } +} + +static void +ast_set_pwm_clock_division_l (struct ast_pwm_controller_data *priv, +u8 pwm_type,u8 div_low) +{ +switch (pwm_type) { +case PWM_TYPE_M : +ast_pwm_controller_write (priv, + (ast_pwm_controller_read (priv,AST_PTCR_CLK_CTRL ) & + ~AST_PTCR_CLK_CTRL_TYPEM_L_MASK ) | + (div_low <<AST_PTCR_CLK_CTRL_TYPEM_L ), +AST_PTCR_CLK_CTRL ); +break ; +case PWM_TYPE_N : +ast_pwm_controller_write (priv, + (ast_pwm_controller_read (priv,AST_PTCR_CLK_CTRL ) & + ~AST_PTCR_CLK_CTRL_TYPEN_L_MASK ) | + (div_low <<AST_PTCR_CLK_CTRL_TYPEN_L ), +AST_PTCR_CLK_CTRL ); +break ; +case PWM_TYPE_O : + ast_pwm_controller_write(priv, + (ast_pwm_controller_read(priv,
AST_PTCR_CLK_EXT_CTRL) &drivers/hwmon/aspeed_pwm_controller.c new file +29
-0+ ~AST_PTCR_CLK_CTRL_TYPEO_L_MASK) | + (div_low <<AST_PTCR_CLK_CTRL_TYPEO_L ), + AST_PTCR_CLK_EXT_CTRL); +break ; + } +} + +static void +ast_set_pwm_clock_unit (struct ast_pwm_controller_data *priv,u8 pwm_type, +u8 unit) +{ +switch (pwm_type) { +case PWM_TYPE_M : +ast_pwm_controller_write (priv, + (ast_pwm_controller_read (priv,AST_PTCR_CLK_CTRL ) & + ~AST_PTCR_CLK_CTRL_TYPEM_UNIT_MASK ) | + (unit <<AST_PTCR_CLK_CTRL_TYPEM_UNIT ), +AST_PTCR_CLK_CTRL ); +break ; +case PWM_TYPE_N : +ast_pwm_controller_write (priv, + (ast_pwm_controller_read (priv,AST_PTCR_CLK_CTRL ) & + ~AST_PTCR_CLK_CTRL_TYPEN_UNIT_MASK ) | + (unit <<AST_PTCR_CLK_CTRL_TYPEN_UNIT ), +AST_PTCR_CLK_CTRL ); +break ; +case PWM_TYPE_O : + ast_pwm_controller_write(priv, + (ast_pwm_controller_read(priv,
AST_PTCR_CLK_EXT_CTRL) &drivers/hwmon/aspeed_pwm_controller.c new file +26
-0+ ~AST_PTCR_CLK_CTRL_TYPEO_UNIT_MASK) | + (unit <<AST_PTCR_CLK_CTRL_TYPEO_UNIT ), + AST_PTCR_CLK_EXT_CTRL); +break ; + } +} + +static int +aspeed_pwm_controller_probe (struct platform_device *pdev) +{ +u32 buf[3 ]; +int err; +struct device_node *np; +struct resource *res; +u8 val; +struct ast_pwm_controller_data *priv; + + np = pdev->dev.of_node; + + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + + priv->base = devm_ioremap(&pdev->dev, res->start,
resource_size(res));drivers/hwmon/aspeed_pwm_controller.c new file +65
-0+if (!priv->base) +return -ENOMEM ; + + err =of_property_read_u8 (np,"clock_enable" , &val); +if (!err) { +ast_set_pwm_clock_enable (priv, val); + }else { +return err; + } + err =of_property_read_u8 (np,"clock_source" , &val); +if (!err) { +ast_set_pwm_clock_source (priv, val); + }else { +return err; + } + + err =of_property_read_u32_array (np,"typem_pwm_clock" , buf,3 ); +if (!err) { +ast_set_pwm_clock_division_l (priv,PWM_TYPE_M , buf[0 ]); +ast_set_pwm_clock_division_h (priv,PWM_TYPE_M , buf[1 ]); +ast_set_pwm_clock_unit (priv,PWM_TYPE_M , buf[2 ]); + } + + err =of_property_read_u32_array (np,"typen_pwm_clock" , buf,3 ); +if (!err) { +ast_set_pwm_clock_division_l (priv,PWM_TYPE_N , buf[0 ]); +ast_set_pwm_clock_division_h (priv,PWM_TYPE_N , buf[1 ]); +ast_set_pwm_clock_unit (priv,PWM_TYPE_N , buf[2 ]); + } + + err =of_property_read_u32_array (np,"typeo_pwm_clock" , buf,3 ); +if (!err) { +ast_set_pwm_clock_division_l (priv,PWM_TYPE_O , buf[0 ]); +ast_set_pwm_clock_division_h (priv,PWM_TYPE_O , buf[1 ]); +ast_set_pwm_clock_unit (priv,PWM_TYPE_O , buf[2 ]); + } + +return 0 ; +} + +static int +aspeed_pwm_controller_remove (struct platform_device *pdev) +{ +return 0 ; +} + +static const struct of_device_id of_pwm_controller_match_table[] = { + { .compatible ="aspeed-pwm-controller" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, of_pwm_controller_match_table); + +static struct platform_driver aspeed_pwm_controller_driver = { + .probe = aspeed_pwm_controller_probe, + .remove = aspeed_pwm_controller_remove, + .driver = { + .name ="aspeed_pwm_controller" , + .owner =THIS_MODULE , + .of_match_table = of_pwm_controller_match_table, + }, +}; + +module_platform_driver (aspeed_pwm_controller_driver); + +MODULE_AUTHOR("Jaghathiswari Rankappagounder Natarajan <[email protected]Quoted 1 line
");
drivers/hwmon/aspeed_pwm_controller.c new file +2
-1+MODULE_DESCRIPTION ("ASPEED PWM controller driver" ); +MODULE_LICENSE ("GPL" ); --2.8.0.rc3.226.g39d4020
_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc
Re: [PATCH linux v1 3/3] devicetree: Add support in Zaius for PWM controller and four PWM outputs(fans)
In reply to Jaghathiswari Rankappagounder NatarajanQuoted 30 lines · Jaghathiswari Rankappagounder Natarajan
--- arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +15
-0@@ -83,6 +83,69 @@ gpios = <&gpio ASPEED_GPIO(H, 7) GPIO_ACTIVE_LOW>; }; }; + + pwm_controller { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-controller"; + clock_enable = /bits/ 8 <0x01>; + clock_source = /bits/ 8 <0x00>; + typem_pwm_clock = <5 0 95>; + }; + + pwm0 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>;
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts line 110
Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +9
-0+ compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default>; + pwm_channel_enable = /bits/ 8 <0x00>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; +
As Andrew mentioned in a reply to your cover letter, please explain the structure of the hardware and the drivers. I see that you are repeating the register address range in each pwmX entry. That should go away if you make the pwmX entries children of the pwm_controller entry. I think you can use address cell in the children to indicate the PWM channel # and let pwm_controller map that back to the correct physical address.
Quoted 50 lines
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +39
-0+ pwm1 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm1_default>; + pwm_channel_enable = /bits/ 8 <0x01>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + + pwm2 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm2_default>; + pwm_channel_enable = /bits/ 8 <0x02>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + + pwm3 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x78>; + compatible = "aspeed-pwm-dev"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm3_default>; + pwm_channel_enable = /bits/ 8 <0x03>; + pwm_type = /bits/ 8 <0x00>; + rising = /bits/ 8 <0x00>; + falling = /bits/ 8 <0x00>; + }; + };&uart5 {
--
2.8.0.rc3.226.g39d4020_______________________________________________
openbmc mailing list
[email protected]
https://lists.ozlabs.org/listinfo/openbmc