Add driver for SIE Cronos control CPLD
Subsystems (2)
v2 cover Add driver for SIE Cronos control CPLD
Hello all,
This series adds a driver for the multi-function CPLD found on the Sony Interactive Entertainment Cronos x86 server platform. It provides a watchdog timer and an LED controller, both of which will depend on the MFD parent driver implemented in this series. Device tree bindings are also included.
Thanks,
Changes in v2:
- Change SIE to Sony (SIE's parent company) to be more consistent with how other subsidiaries are treated in the kernel.
- Drop SIE prefix addition patch
- Address review comments to dt bindings
- Add new properties to dt bindings
- Fix driver build failure detected by kernel test robot
Shawn Anastasio (1):
dt-bindings: mfd: Add sony,cronos-cpld
Timothy Pearson (1):
mfd: sie-cronos-cpld: Add driver for Sony Cronos CPLD
.../bindings/mfd/sony,cronos-cpld.yaml | 92 +++ MAINTAINERS | 7 + drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/sony-cronos-cpld.c | 591 ++++++++++++++++++ include/linux/mfd/sony/cronos/core.h | 17 + include/linux/mfd/sony/cronos/registers.h | 59 ++ 7 files changed, 778 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml create mode 100644 drivers/mfd/sony-cronos-cpld.c create mode 100644 include/linux/mfd/sony/cronos/core.h create mode 100644 include/linux/mfd/sony/cronos/registers.h
--
2.30.2
PATCH v2 1/2 dt-bindings: mfd: Add sony,cronos-cpld
The Sony Cronos Platform Controller CPLD is a multi-purpose platform controller that provides both a watchdog timer and an LED controller for the Sony Interactive Entertainment Cronos x86 server platform. As both functions are provided by the same CPLD, a multi-function device is exposed as the parent of both functions.
Add a DT binding for this device.
---
Changes in v2:
- Change SIE to Sony to use the already-established prefix.
- Clarify that Cronos is an x86 server platform in description
- Drop #address-cells/#size-cells
- Add missing additionalProperties to leds/watchdog objects
- Add sony,led-mask property to leds object
- Add sony,default-timeout property to watchdog object
- Update example
.../bindings/mfd/sony,cronos-cpld.yaml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +92 -0
@@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Raptor Engineering, LLC +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/sony,cronos-cpld.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony Cronos Platform Controller CPLD multi-function device + +maintainers: + - Timothy Pearson <[email protected]> + +description: | + The Sony Cronos Platform Controller CPLD is a multi-purpose platform + controller that provides both a watchdog timer and an LED controller for the + Sony Interactive Entertainment Cronos x86 server platform. As both functions + are provided by the same CPLD, a multi-function device is exposed as the + parent of both functions. + +properties: + compatible: + const: sony,cronos-cpld + + reg: + maxItems: 1 + + leds: + type: object + description: Cronos Platform Status LEDs + + properties: + compatible: + const: sony,cronos-leds + + sony,led-mask: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0x0 + maximum: 0x7fff + description: | + A bitmask that specifies which LEDs are present and can be controlled + by the Cronos CPLD. Bits 0-5 correspond to platform Status LEDs, bits + 6-10 correspond to Link LEDs, and bits 11-14 correspond to the Power + State LEDs. All other bits are unused. The default value is 0x7fff + (all possible LEDs enabled). + + additionalProperties: false + + watchdog: + type: object + description: Cronos Platform Watchdog Timer + + properties: + compatible: + const: sony,cronos-watchdog + + sony,default-timeout: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The default timeout with which the watchdog timer is initialized, in + seconds. Supported values are: 10, 20, 30, 40, 50, 60, 70, 80. All + other values will be rounded down to the nearest supported value. The + default value is 80. + + additionalProperties: false + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + cpld@3f { + compatible = "sony,cronos-cpld"; + reg = <0x3f>; + + watchdog { + compatible = "sony,cronos-watchdog"; + sony,default-timeout = <20>; + }; + + leds { + compatible = "sony,cronos-leds"; + sony,led-mask = <0x7fff>; + }; + }; + };
--
2.30.2
Re: [PATCH v2 1/2] dt-bindings: mfd: Add sony,cronos-cpld
Quoted 48 lines · Shawn Anastasio
The Sony Cronos Platform Controller CPLD is a multi-purpose platform controller that provides both a watchdog timer and an LED controller for the Sony Interactive Entertainment Cronos x86 server platform. As both functions are provided by the same CPLD, a multi-function device is exposed as the parent of both functions.
Add a DT binding for this device.
Signed-off-by Shawn Anastasio <[email protected]>---
Changes in v2:
- Change SIE to Sony to use the already-established prefix.
- Clarify that Cronos is an x86 server platform in description
- Drop #address-cells/#size-cells
- Add missing additionalProperties to leds/watchdog objects
- Add sony,led-mask property to leds object
- Add sony,default-timeout property to watchdog object
- Update example.../bindings/mfd/sony,cronos-cpld.yaml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yamlDocumentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +19
-0@@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Raptor Engineering, LLC +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/sony,cronos-cpld.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony Cronos Platform Controller CPLD multi-function device + +maintainers: + - Timothy Pearson <[email protected]> + +description: | + The Sony Cronos Platform Controller CPLD is a multi-purpose platform + controller that provides both a watchdog timer and an LED controller for the + Sony Interactive Entertainment Cronos x86 server platform. As both functions + are provided by the same CPLD, a multi-function device is exposed as the + parent of both functions. +
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +10
-0+properties: + compatible: + const: sony,cronos-cpld + + reg: + maxItems: 1 + + leds: + type: object + description: Cronos Platform Status LEDs
Missing ref to LEDs common bindings.
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 36
Quoted 7 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +7
-0+ + properties: + compatible: + const: sony,cronos-leds + + sony,led-mask: + $ref: /schemas/types.yaml#/definitions/uint32
Why aren't you using LEDs bindings? A node for one property is otherwise quite useless. I already commented on this last time.
Quoted 12 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +12
-0+ minimum: 0x0 + maximum: 0x7fff + description: | + A bitmask that specifies which LEDs are present and can be controlled + by the Cronos CPLD. Bits 0-5 correspond to platform Status LEDs, bits + 6-10 correspond to Link LEDs, and bits 11-14 correspond to the Power + State LEDs. All other bits are unused. The default value is 0x7fff + (all possible LEDs enabled). + + additionalProperties: false + + watchdog:
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +8
-0+ type: object + description: Cronos Platform Watchdog Timer + + properties: + compatible: + const: sony,cronos-watchdog + + sony,default-timeout:
No, you must use existing bindings. Missing ref to watchdog and drop all duplicated properties like this one.
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 63
Quoted 7 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +7
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The default timeout with which the watchdog timer is initialized, in + seconds. Supported values are: 10, 20, 30, 40, 50, 60, 70, 80. All + other values will be rounded down to the nearest supported value. The + default value is 80. +
Best regards,
Krzysztof
Re: [PATCH v2 1/2] dt-bindings: mfd: Add sony,cronos-cpld
Quoted 53 lines · Krzysztof Kozlowski
Quoted 52 lines · Shawn Anastasio
The Sony Cronos Platform Controller CPLD is a multi-purpose platform controller that provides both a watchdog timer and an LED controller for the Sony Interactive Entertainment Cronos x86 server platform. As both functions are provided by the same CPLD, a multi-function device is exposed as the parent of both functions.
Add a DT binding for this device.
Signed-off-by Shawn Anastasio <[email protected]>---
Changes in v2:
- Change SIE to Sony to use the already-established prefix.
- Clarify that Cronos is an x86 server platform in description
- Drop #address-cells/#size-cells
- Add missing additionalProperties to leds/watchdog objects
- Add sony,led-mask property to leds object
- Add sony,default-timeout property to watchdog object
- Update example.../bindings/mfd/sony,cronos-cpld.yaml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yamlDocumentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +23
-0@@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Raptor Engineering, LLC +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/sony,cronos-cpld.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony Cronos Platform Controller CPLD multi-function device + +maintainers: + - Timothy Pearson <[email protected]> + +description: | + The Sony Cronos Platform Controller CPLD is a multi-purpose platform + controller that provides both a watchdog timer and an LED controller for the + Sony Interactive Entertainment Cronos x86 server platform. As both functions + are provided by the same CPLD, a multi-function device is exposed as the + parent of both functions. + +properties: + compatible: + const: sony,cronos-cpld +
Quoted 9 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 29
Quoted 6 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +6
-0+ reg: + maxItems: 1 + + leds: + type: object + description: Cronos Platform Status LEDsMissing ref to LEDs common bindings.
Will fix.
Quoted 11 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 36
Quoted 7 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +7
-0+ + properties: + compatible: + const: sony,cronos-leds + + sony,led-mask: + $ref: /schemas/types.yaml#/definitions/uint32Why aren't you using LEDs bindings? A node for one property is otherwise quite useless. I already commented on this last time.
Our driver as-is doesn't support any of the properties in the LEDs common bindings, but it doesn't seem like there's anything that would preclude support in hardware, so this can be fixed.
Will use the LED bindings in v3.
Quoted 16 lines
Quoted 14 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +14
-0+ minimum: 0x0 + maximum: 0x7fff + description: | + A bitmask that specifies which LEDs are present and can be controlled + by the Cronos CPLD. Bits 0-5 correspond to platform Status LEDs, bits + 6-10 correspond to Link LEDs, and bits 11-14 correspond to the Power + State LEDs. All other bits are unused. The default value is 0x7fff + (all possible LEDs enabled). + + additionalProperties: false + + watchdog: + type: object + description: Cronos Platform Watchdog Timer
Quoted 10 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 56
Quoted 6 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +6
-0+ + properties: + compatible: + const: sony,cronos-watchdog + + sony,default-timeout:No, you must use existing bindings. Missing ref to watchdog and drop all duplicated properties like this one.
In this case the existing watchdog binding allows for arbitrary timeout values to be set, but the hardware only tolerates one of a few fixed values, enumerated below, which is why I felt it was appropriate to use a vendor-specific binding that documents the supported values.
Would you still prefer we ref to watchdog and just handle unsupported values in the driver by e.g. rounding or rejecting unsupported values?
Quoted 10 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 63
Quoted 7 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +7
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: | + The default timeout with which the watchdog timer is initialized, in + seconds. Supported values are: 10, 20, 30, 40, 50, 60, 70, 80. All + other values will be rounded down to the nearest supported value. The + default value is 80. +
Quoted 3 lines
Best regards,
Krzysztof
Thanks,
Shawn
Re: [PATCH v2 1/2] dt-bindings: mfd: Add sony,cronos-cpld
Quoted 28 lines · Shawn Anastasio
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +4
-0+properties: + compatible: + const: sony,cronos-cpld +Quoted 9 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 29
Quoted 6 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +6
-0+ reg: + maxItems: 1 + + leds: + type: object + description: Cronos Platform Status LEDsMissing ref to LEDs common bindings.
Will fix.
Quoted 11 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 36
Quoted 7 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +7
-0+ + properties: + compatible: + const: sony,cronos-leds + + sony,led-mask: + $ref: /schemas/types.yaml#/definitions/uint32Why aren't you using LEDs bindings? A node for one property is otherwise quite useless. I already commented on this last time.
Quoted 3 lines
Our driver as-is doesn't support any of the properties in the LEDs common bindings, but it doesn't seem like there's anything that would preclude support in hardware, so this can be fixed.
Driver does not matter. We talk here about bindings, so about hardware, not driver.
You must describe here hardware fully, not the driver.
Quoted 30 lines
Will use the LED bindings in v3.
Quoted 16 lines
Quoted 14 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +14
-0+ minimum: 0x0 + maximum: 0x7fff + description: | + A bitmask that specifies which LEDs are present and can be controlled + by the Cronos CPLD. Bits 0-5 correspond to platform Status LEDs, bits + 6-10 correspond to Link LEDs, and bits 11-14 correspond to the Power + State LEDs. All other bits are unused. The default value is 0x7fff + (all possible LEDs enabled). + + additionalProperties: false + + watchdog: + type: object + description: Cronos Platform Watchdog TimerQuoted 10 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml line 56
Quoted 6 lines
Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml new file +6
-0+ + properties: + compatible: + const: sony,cronos-watchdog + + sony,default-timeout:No, you must use existing bindings. Missing ref to watchdog and drop all duplicated properties like this one.
Quoted 4 lines
In this case the existing watchdog binding allows for arbitrary timeout values to be set, but the hardware only tolerates one of a few fixed values, enumerated below, which is why I felt it was appropriate to use a vendor-specific binding that documents the supported values.
You can narrow the accepted values.
Quoted 3 lines
Would you still prefer we ref to watchdog and just handle unsupported values in the driver by e.g. rounding or rejecting unsupported values?
It's not preference, it's a must.
Best regards,
Krzysztof
PATCH v2 2/2 mfd: sie-cronos-cpld: Add driver for Sony Cronos CPLD
In reply to Shawn AnastasioFrom: Timothy Pearson <[email protected]>
The Sony Cronos Platform Controller CPLD is a multi-purpose platform controller that provides both a watchdog timer and an LED controller for the Sony Interactive Entertainment Cronos x86 server platform. As both functions are provided by the same CPLD, a multi-function device is exposed as the parent of both functions.
---
Changes in v2:
- Change SIE to Sony (SIE's parent company) to be more consistent with how other subsidiaries are treated in the kernel
- Fix build issue under !CONFIG_OF discovered by kernel test robot by guarding definition of cronos_cpld_dt_ids as is done in other drivers.
MAINTAINERS | 7 + drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/sony-cronos-cpld.c | 591 ++++++++++++++++++++++ include/linux/mfd/sony/cronos/core.h | 17 + include/linux/mfd/sony/cronos/registers.h | 59 +++ 6 files changed, 686 insertions(+) create mode 100644 drivers/mfd/sony-cronos-cpld.c create mode 100644 include/linux/mfd/sony/cronos/core.h create mode 100644 include/linux/mfd/sony/cronos/registers.h
MAINTAINERS +7 -0
@@ -19932,6 +19932,13 @@ S: Maintained F: drivers/ssb/ F: include/linux/ssb/ +SONY CRONOS CPLD DRIVER +M: Georgy Yakovlev <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml +F: drivers/mfd/sony-cronos-cpld.c +F: include/linux/mfd/sony/cronos/ + SONY IMX208 SENSOR DRIVER M: Sakari Ailus <[email protected]> L: [email protected]
drivers/mfd/Kconfig +11 -0
@@ -2217,6 +2217,17 @@ config MFD_QCOM_PM8008 under it in the device tree. Additional drivers must be enabled in order to use the functionality of the device. +config MFD_SONY_CRONOS_CPLD + tristate "Sony Cronos CPLD Support" + select MFD_CORE + select REGMAP_I2C + depends on I2C + help + Support for the Sony Cronos system control CPLDs. Additional drivers must + be enabled in order to use the functionality of the device, including LED + control and the system watchdog. The controller itself is a custom design + tailored to the specific needs of the Sony Cronos hardware platform. + menu "Multimedia Capabilities Port drivers" depends on ARCH_SA1100
drivers/mfd/Makefile +1 -0
@@ -284,3 +284,4 @@ rsmu-i2c-objs := rsmu_core.o rsmu_i2c.o rsmu-spi-objs := rsmu_core.o rsmu_spi.o obj-$(CONFIG_MFD_RSMU_I2C) += rsmu-i2c.o obj-$(CONFIG_MFD_RSMU_SPI) += rsmu-spi.o +obj-$(CONFIG_MFD_SONY_CRONOS_CPLD) += sony-cronos-cpld.o
drivers/mfd/sony-cronos-cpld.c new file +591 -0
591 lines not on this page · raw message
include/linux/mfd/sony/cronos/core.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2015-2017 Dialog Semiconductor +* Copyright (C) 2022 Raptor Engineering, LLC +*/ + +#ifndef __MFD_SONY_CRONOS_CORE_H__ +#define __MFD_SONY_CRONOS_CORE_H__ + +#include <linux/mfd/sony/cronos/registers.h> + +struct sony_cronos_cpld { +struct device *dev; +struct regmap *regmap; +}; + +#endif /* __MFD_SONY_CRONOS_H__ */
include/linux/mfd/sony/cronos/registers.h new file +59 -0
59 lines not on this page · raw message
--
2.30.2
Lee Jones
maintainerRe: [PATCH v2 2/2] mfd: sie-cronos-cpld: Add driver for Sony Cronos CPLD
Quoted 8 lines · Shawn Anastasio
From: Timothy Pearson <[email protected]>
The Sony Cronos Platform Controller CPLD is a multi-purpose platform controller that provides both a watchdog timer and an LED controller for the Sony Interactive Entertainment Cronos x86 server platform. As both functions are provided by the same CPLD, a multi-function device is exposed as the parent of both functions.
Quoted 7 lines
Signed-off-by Timothy Pearson <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>---
Changes in v2:
- Change SIE to Sony (SIE's parent company) to be more consistent with how other subsidiaries are treated in the kernel
- Fix build issue under !CONFIG_OF discovered by kernel test robot
Does this driver work without Device Tree?
Why can't you just drop the of_match_ptr()?
Quoted 19 lines
by guarding definition of
cronos_cpld_dt_idsas is done in other drivers.MAINTAINERS | 7 + drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/sony-cronos-cpld.c | 591 ++++++++++++++++++++++ include/linux/mfd/sony/cronos/core.h | 17 + include/linux/mfd/sony/cronos/registers.h | 59 +++ 6 files changed, 686 insertions(+) create mode 100644 drivers/mfd/sony-cronos-cpld.c create mode 100644 include/linux/mfd/sony/cronos/core.h create mode 100644 include/linux/mfd/sony/cronos/registers.hMAINTAINERS +0
-0
MAINTAINERS S: Maintained · line 19936
Quoted 5 lines
MAINTAINERS +2
-0@@ -19932,6 +19932,13 @@ S: Maintained F: drivers/ssb/ F: include/linux/ssb/ +SONY CRONOS CPLD DRIVER +M: Georgy Yakovlev <[email protected]>
Are they aware of this?
They do not appear to be in the submission path.
MAINTAINERS S: Maintained · line 19937
Quoted 1 line
MAINTAINERS +1
-0+S: Maintained
This should probably be Supported.
Quoted 44 lines
MAINTAINERS +4
-0+F: Documentation/devicetree/bindings/mfd/sony,cronos-cpld.yaml +F: drivers/mfd/sony-cronos-cpld.c +F: include/linux/mfd/sony/cronos/ + SONY IMX208 SENSOR DRIVER M: Sakari Ailus <[email protected]> L: [email protected]drivers/mfd/Kconfig +11
-0@@ -2217,6 +2217,17 @@ config MFD_QCOM_PM8008 under it in the device tree. Additional drivers must be enabled in order to use the functionality of the device. +config MFD_SONY_CRONOS_CPLD + tristate "Sony Cronos CPLD Support" + select MFD_CORE + select REGMAP_I2C + depends on I2C + help + Support for the Sony Cronos system control CPLDs. Additional drivers must + be enabled in order to use the functionality of the device, including LED + control and the system watchdog. The controller itself is a custom design + tailored to the specific needs of the Sony Cronos hardware platform. + menu "Multimedia Capabilities Port drivers" depends on ARCH_SA1100drivers/mfd/Makefile +1
-0@@ -284,3 +284,4 @@ rsmu-i2c-objs := rsmu_core.o rsmu_i2c.o rsmu-spi-objs := rsmu_core.o rsmu_spi.o obj-$(CONFIG_MFD_RSMU_I2C) += rsmu-i2c.o obj-$(CONFIG_MFD_RSMU_SPI) += rsmu-spi.o +obj-$(CONFIG_MFD_SONY_CRONOS_CPLD) += sony-cronos-cpld.odrivers/mfd/sony-cronos-cpld.c new file +0
-0
drivers/mfd/sony-cronos-cpld.c line 3
Quoted 3 lines
drivers/mfd/sony-cronos-cpld.c new file +3
-0@@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* I2C device driver for Sony Cronos CPLDs
This is not an I2C device driver.
drivers/mfd/sony-cronos-cpld.c line 5
Quoted 2 lines
drivers/mfd/sony-cronos-cpld.c new file +2
-0+* Copyright (C) 2015-2017 Dialog Semiconductor +* Copyright (C) 2022 Raptor Engineering, LLC
No changes since 2022?
drivers/mfd/sony-cronos-cpld.c line 17
Quoted 12 lines
drivers/mfd/sony-cronos-cpld.c new file +12
-0+*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/device.h> +#include <linux/interrupt.h> +#include <linux/regmap.h> +#include <linux/mfd/core.h> +#include <linux/i2c.h> +#include <linux/mfd/sony/cronos/core.h> +#include <linux/mfd/sony/cronos/registers.h>
Alphabetical.
drivers/mfd/sony-cronos-cpld.c line 23
Quoted 5 lines
drivers/mfd/sony-cronos-cpld.c new file +5
-0+static struct resource cronos_wdt_resources[] = { +}; + +static struct resource cronos_led_resources[] = { +};
What is the point of these?
drivers/mfd/sony-cronos-cpld.c line 34
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+static const struct mfd_cell cronos_cpld_devs[] = { + { + .name ="cronos-watchdog" , + .num_resources =ARRAY_SIZE (cronos_wdt_resources), + .resources = cronos_wdt_resources, + .of_compatible ="sony,cronos-watchdog" , + }, + { + .name ="cronos-leds" , + .id =1 ,
Why are you manually numbering them?
drivers/mfd/sony-cronos-cpld.c line 43
Quoted 9 lines
drivers/mfd/sony-cronos-cpld.c new file +9
-0+ .num_resources = ARRAY_SIZE(cronos_led_resources), + .resources = cronos_led_resources, + .of_compatible = "sony,cronos-leds", + }, +}; + +static ssize_t payload_power_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +unsigned int payloadpower_val =0 ;
Ironically, the "_val" provides no value here.
drivers/mfd/sony-cronos-cpld.c line 42
Quoted 1 line
drivers/mfd/sony-cronos-cpld.c new file +1
-0+int ret = -EIO ;
Why is this being pre-initialised? Same throughout.
drivers/mfd/sony-cronos-cpld.c line 43
Quoted 1 line
drivers/mfd/sony-cronos-cpld.c new file +1
-0+struct sony_cronos_cpld *chip =dev_get_drvdata (dev);
Move this line to the top - same throughout.
drivers/mfd/sony-cronos-cpld.c line 45
Quoted 2 lines
drivers/mfd/sony-cronos-cpld.c new file +2
-0+ ret =regmap_read (chip->regmap,CRONOS_CPLD_PAYLOAD_POWER_CTL_REG , &payloadpower_val); +if (ret <0 )
if (ret) is fine. For all cases below too.
drivers/mfd/sony-cronos-cpld.c line 51
Quoted 3 lines
drivers/mfd/sony-cronos-cpld.c new file +3
-0+return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , payloadpower_val);
sysfs_emit(). For all cases below too.
Quoted 7 lines
drivers/mfd/sony-cronos-cpld.c new file +7
-0+} + +static ssize_t payload_power_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +u8 val =0 ;
drivers/mfd/sony-cronos-cpld.c line 68
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +if (kstrtou8 (buf,0 , &val)) +return -EINVAL ; + + ret =regmap_write (chip->regmap,CRONOS_CPLD_PAYLOAD_POWER_CTL_REG , val); +if (ret) { +dev_err (dev,"Failed to write value 0x%02x to address 0x%02x" , + val,CRONOS_CPLD_PAYLOAD_POWER_CTL_REG );
Why dump an error messages here and not in other places?
I suggest they are dropped.
Quoted 216 lines
drivers/mfd/sony-cronos-cpld.c new file +216
-0+return ret; + } +return len; +} + + +static ssize_t bmc_flash_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +unsigned int bmcflash_val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_read (chip->regmap,CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG , &bmcflash_val); +if (ret <0 ) +return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , bmcflash_val); +} + +static ssize_t bmc_flash_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +u8 val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +if (kstrtou8 (buf,0 , &val)) +return -EINVAL ; + + ret =regmap_write (chip->regmap,CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG , val); +if (ret) { +dev_err (dev,"Failed to write value 0x%02x to address 0x%02x" , + val,CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG ); +return ret; + } +return len; +} + + +static ssize_t switch_reset_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +unsigned int switchreset_val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_read (chip->regmap,CRONOS_CPLD_SWITCH_RESET_CMD_REG , &switchreset_val); +if (ret <0 ) +return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , switchreset_val); +} + +static ssize_t switch_reset_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +unsigned int switchreset_val =0 ; +u8 val = -EINVAL ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +if (kstrtou8 (buf,0 , &val)) +return -EINVAL ; + +if (val !=1 ) +return -EINVAL ; + + ret =regmap_read (chip->regmap,CRONOS_CPLD_SWITCH_RESET_CMD_REG , &switchreset_val); +if (ret <0 ) +return ret; + + ret =regmap_write (chip->regmap,CRONOS_CPLD_SWITCH_RESET_CMD_REG , switchreset_val); +if (ret) { +dev_err (dev,"Failed to write value 0x%02x to address 0x%02x" , + switchreset_val,CRONOS_CPLD_SWITCH_RESET_CMD_REG ); +return ret; + } +return len; +} + + +static ssize_t switch_flash_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +unsigned int switchflash_val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_read (chip->regmap,CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG , &switchflash_val); +if (ret <0 ) +return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , switchflash_val); +} + +static ssize_t switch_flash_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +u8 val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +if (kstrtou8 (buf,0 , &val)) +return -EINVAL ; + + ret =regmap_write (chip->regmap,CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG , val); +if (ret) { +dev_err (dev,"Failed to write value 0x%02x to address 0x%02x" , + val,CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG ); +return ret; + } +return len; +} + + +static ssize_t uart_mux_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +unsigned int uartmux_val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_read (chip->regmap,CRONOS_CPLD_UART_MUX_REG , &uartmux_val); +if (ret <0 ) +return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , uartmux_val); +} + +static ssize_t uart_mux_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +u8 val =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +if (kstrtou8 (buf,0 , &val)) +return -EINVAL ; + + ret =regmap_write (chip->regmap,CRONOS_CPLD_UART_MUX_REG , val); +if (ret) { +dev_err (dev,"Failed to write value 0x%02x to address 0x%02x" , + val,CRONOS_CPLD_UART_MUX_REG ); +return ret; + } +return len; +} + + +static ssize_t led_get_brightness (struct sony_cronos_cpld *chip,unsigned int reg,char *buf) +{ +unsigned int brightness_val; +int ret = -EIO ; + + ret =regmap_read (chip->regmap, reg, &brightness_val); +if (ret !=0 ) +return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , brightness_val); +} + +static ssize_t led_set_brightness (struct sony_cronos_cpld *chip,unsigned int reg,const char *buf, +size_t len) +{ +u8 val =0 ; +int ret = -EIO ; + +if (kstrtou8 (buf,0 , &val)) +return -EINVAL ; + + ret =regmap_update_bits (chip->regmap, reg,CRONOS_CPLD_LEDS_BRIGHTNESS_SET_MASK , val); +if (ret) { +dev_err (chip->dev,"Failed to write value 0x%02x to address 0x%02x" , val, reg); +return ret; + } +return len; +} + +static ssize_t brightness_red_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +return led_get_brightness (chip,CRONOS_CPLD_BRIGHTNESS_RED_REG , buf); +} + +static ssize_t brightness_red_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +return led_set_brightness (chip,CRONOS_CPLD_BRIGHTNESS_RED_REG , buf, len); +} + +static ssize_t brightness_green_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +return led_get_brightness (chip,CRONOS_CPLD_BRIGHTNESS_GREEN_REG , buf); +} + +static ssize_t brightness_green_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +return led_set_brightness (chip,CRONOS_CPLD_BRIGHTNESS_GREEN_REG , buf, len); +} + +static ssize_t brightness_blue_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +return led_get_brightness (chip,CRONOS_CPLD_BRIGHTNESS_BLUE_REG , buf);
drivers/mfd/sony-cronos-cpld.c line 294
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+} + +static ssize_t brightness_blue_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + +return led_set_brightness (chip,CRONOS_CPLD_BRIGHTNESS_BLUE_REG , buf, len); +}
All of the LED related code should be in the LED driver.
drivers/mfd/sony-cronos-cpld.c line 293
Quoted 2 lines
drivers/mfd/sony-cronos-cpld.c new file +2
-0+ +
No double line spacings.
Quoted 57 lines
drivers/mfd/sony-cronos-cpld.c new file +57
-0+static ssize_t revision_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +u16 revision =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_bulk_read (chip->regmap,CRONOS_CPLD_REVISION_LOW_REG , &revision,2 ); +if (ret) +return -EIO ; + +return snprintf (buf,PAGE_SIZE ,"0x%04x\n" , revision); +} + +static ssize_t device_id_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +u16 device_id =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_bulk_read (chip->regmap,CRONOS_CPLD_DEVICE_ID_LOW_REG , &device_id,2 ); +if (ret) +return -EIO ; + +return snprintf (buf,PAGE_SIZE ,"0x%04x\n" , device_id); +} + +static ssize_t bmc_mac_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +u8 bmc_mac[6 ]; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_bulk_read (chip->regmap,CRONOS_CPLD_BMC_MAC_LOW_REG , bmc_mac,6 ); +if (ret) +return -EIO ; + +return snprintf (buf,PAGE_SIZE ,"%pM\n" , bmc_mac); +} + +static ssize_t status_2_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +unsigned int last_boot =0 ; +int ret = -EIO ; +struct sony_cronos_cpld *chip =dev_get_drvdata (dev); + + ret =regmap_read (chip->regmap,CRONOS_CPLD_STATUS_2_REG , &last_boot); +if (ret <0 ) +return ret; + +return snprintf (buf,PAGE_SIZE ,"0x%02x\n" , last_boot); +} + + +static DEVICE_ATTR_RO (revision); +static DEVICE_ATTR_RO (device_id); +static DEVICE_ATTR_RO (bmc_mac); +static DEVICE_ATTR_RO (status_2);
drivers/mfd/sony-cronos-cpld.c line 363
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+ +static DEVICE_ATTR_RW (uart_mux); +static DEVICE_ATTR_RW (switch_flash); +static DEVICE_ATTR_RW (switch_reset); +static DEVICE_ATTR_RW (bmc_flash); +static DEVICE_ATTR_RW (payload_power); + +static DEVICE_ATTR_RW (brightness_red); +static DEVICE_ATTR_RW (brightness_green); +static DEVICE_ATTR_RW (brightness_blue);
'\n'
Quoted 5 lines
drivers/mfd/sony-cronos-cpld.c new file +5
-0+static struct attribute *cronos_cpld_sysfs_entries[] = { + &dev_attr_revision.attr, + &dev_attr_device_id.attr, + &dev_attr_bmc_mac.attr, + &dev_attr_status_2.attr,
drivers/mfd/sony-cronos-cpld.c line 378
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+ &dev_attr_uart_mux.attr, + &dev_attr_switch_flash.attr, + &dev_attr_switch_reset.attr, + &dev_attr_bmc_flash.attr, + &dev_attr_payload_power.attr, + &dev_attr_brightness_red.attr, + &dev_attr_brightness_green.attr, + &dev_attr_brightness_blue.attr, + NULL, +};
These all need to be documented or dropped.
Please read:
Documentation/filesystems/sysfs.rst
And do:
find Documentation -name *sysfs*
drivers/mfd/sony-cronos-cpld.c line 387
Quoted 8 lines
drivers/mfd/sony-cronos-cpld.c new file +8
-0+static const struct attribute_group cronos_cpld_attr_group = { + .attrs = cronos_cpld_sysfs_entries, +}; + +static int sony_cronos_get_device_type (struct sony_cronos_cpld *chip) +{ +int device_id; +int byte;
Introduce 2 variables and do all of the bit manipulation at the bottom.
drivers/mfd/sony-cronos-cpld.c line 394
Quoted 7 lines
drivers/mfd/sony-cronos-cpld.c new file +7
-0+int ret; + + ret =regmap_read (chip->regmap,CRONOS_CPLD_DEVICE_ID_HIGH_REG , &byte); +if (ret <0 ) { +dev_err (chip->dev,"Cannot read chip ID.\n" ); +return -EIO ; + }
Spread these out with '\n's.
drivers/mfd/sony-cronos-cpld.c line 403
Quoted 9 lines
drivers/mfd/sony-cronos-cpld.c new file +9
-0+ device_id = byte <<8 ; + ret =regmap_read (chip->regmap,CRONOS_CPLD_DEVICE_ID_LOW_REG , &byte); +if (ret <0 ) { +dev_err (chip->dev,"Cannot read chip ID.\n" ); +return -EIO ; + } + device_id |= byte; +if (device_id !=CRONOS_CPLD_DEVICE_ID ) { +dev_err (chip->dev,"Invalid device ID: 0x%04x\n" , device_id);
"Unsupported"
drivers/mfd/sony-cronos-cpld.c line 409
Quoted 6 lines
drivers/mfd/sony-cronos-cpld.c new file +6
-0+return -ENODEV ; + } + +dev_info (chip->dev, +"Device detected (device-ID: 0x%04X)\n" , + device_id);
Why line break here? The lines above are way longer.
Quoted 86 lines
drivers/mfd/sony-cronos-cpld.c new file +86
-0+return ret; +} + +static bool cronos_cpld_is_writeable_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { +case CRONOS_CPLD_BRIGHTNESS_RED_REG : +case CRONOS_CPLD_BRIGHTNESS_GREEN_REG : +case CRONOS_CPLD_BRIGHTNESS_BLUE_REG : +case CRONOS_LEDS_SMC_STATUS_REG : +case CRONOS_LEDS_SWITCH_STATUS_REG : +case CRONOS_LEDS_CCM1_STATUS_REG : +case CRONOS_LEDS_CCM2_STATUS_REG : +case CRONOS_LEDS_CCM3_STATUS_REG : +case CRONOS_LEDS_CCM4_STATUS_REG : +case CRONOS_LEDS_CCM_POWER_REG : + +case CRONOS_WDT_CTL_REG : +case CRONOS_WDT_CLR_REG : + +case CRONOS_CPLD_UART_MUX_REG : +case CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG : +case CRONOS_CPLD_SWITCH_RESET_CMD_REG : +case CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG : +case CRONOS_CPLD_PAYLOAD_POWER_CTL_REG : +return true; +default : +return false; + } +} + +static bool cronos_cpld_is_readable_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { +case CRONOS_CPLD_REVISION_HIGH_REG : +case CRONOS_CPLD_REVISION_LOW_REG : +case CRONOS_CPLD_DEVICE_ID_HIGH_REG : +case CRONOS_CPLD_DEVICE_ID_LOW_REG : + +case CRONOS_CPLD_BRIGHTNESS_RED_REG : +case CRONOS_CPLD_BRIGHTNESS_GREEN_REG : +case CRONOS_CPLD_BRIGHTNESS_BLUE_REG : +case CRONOS_LEDS_SMC_STATUS_REG : +case CRONOS_LEDS_SWITCH_STATUS_REG : +case CRONOS_LEDS_CCM1_STATUS_REG : +case CRONOS_LEDS_CCM2_STATUS_REG : +case CRONOS_LEDS_CCM3_STATUS_REG : +case CRONOS_LEDS_CCM4_STATUS_REG : +case CRONOS_LEDS_CCM_POWER_REG : + +case CRONOS_WDT_CTL_REG : +case CRONOS_WDT_CLR_REG : + +case CRONOS_CPLD_STATUS_2_REG : +case CRONOS_CPLD_UART_MUX_REG : +case CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG : +case CRONOS_CPLD_SWITCH_RESET_CMD_REG : +case CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG : +case CRONOS_CPLD_PAYLOAD_POWER_CTL_REG : + + case CRONOS_CPLD_BMC_MAC_LOW_REG ... CRONOS_CPLD_BMC_MAC_HIGH_REG: +return true; +default : +return false; + } +} + +static bool cronos_cpld_is_volatile_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { +case CRONOS_CPLD_REVISION_HIGH_REG : +case CRONOS_CPLD_REVISION_LOW_REG : + +case CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG : +case CRONOS_CPLD_SWITCH_RESET_CMD_REG : +case CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG : +case CRONOS_CPLD_PAYLOAD_POWER_CTL_REG : + +case CRONOS_WDT_CTL_REG : +case CRONOS_WDT_CLR_REG : +return true; +default : +return false; + } +} +
drivers/mfd/sony-cronos-cpld.c line 506
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+static struct regmap_config cronos_cpld_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .max_register =CRONOS_CPLD_REVISION_HIGH_REG , + .writeable_reg = cronos_cpld_is_writeable_reg, + .readable_reg = cronos_cpld_is_readable_reg, + .volatile_reg = cronos_cpld_is_volatile_reg, + .use_single_read = true, + .use_single_write = true, + .cache_type =REGCACHE_RBTREE ,
This is being phased out for the Maple Tree.
drivers/mfd/sony-cronos-cpld.c line 509
Quoted 3 lines
drivers/mfd/sony-cronos-cpld.c new file +3
-0+}; + +#ifdef CONFIG_OF
These are ugly and shouldn't be required.
drivers/mfd/sony-cronos-cpld.c line 519
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+static const struct of_device_id cronos_cpld_dt_ids[] = { + { .compatible ="sony,cronos-cpld" , }, + { } +}; +MODULE_DEVICE_TABLE (of, cronos_cpld_dt_ids); +#endif + +static int sony_cronos_i2c_probe (struct i2c_client *i2c) +{ +struct sony_cronos_cpld *chip;
Chip is wrong here. This should be ddata.
drivers/mfd/sony-cronos-cpld.c line 521
Quoted 2 lines
drivers/mfd/sony-cronos-cpld.c new file +2
-0+const struct of_device_id *match; +const struct mfd_cell *cell;
Why do you need this?
drivers/mfd/sony-cronos-cpld.c line 531
Quoted 10 lines
drivers/mfd/sony-cronos-cpld.c new file +10
-0+const struct regmap_config *config; +int cell_num; +int ret; + + chip =devm_kzalloc (&i2c->dev,sizeof (*chip),GFP_KERNEL ); +if (!chip) +return -ENOMEM ; + +if (i2c->dev.of_node) { + match =of_match_node (cronos_cpld_dt_ids, i2c->dev.of_node);
Why are you doing this?
drivers/mfd/sony-cronos-cpld.c line 536
Quoted 5 lines
drivers/mfd/sony-cronos-cpld.c new file +5
-0+if (!match) +return -EINVAL ; + } + +i2c_set_clientdata (i2c, chip);
Do this *after* the struct has been populated.
drivers/mfd/sony-cronos-cpld.c line 541
Quoted 5 lines
drivers/mfd/sony-cronos-cpld.c new file +5
-0+ chip->dev = &i2c->dev; + + cell = cronos_cpld_devs; + cell_num =ARRAY_SIZE (cronos_cpld_devs); + config = &cronos_cpld_regmap_config;
This is bananas. Why the intermediary variables?
drivers/mfd/sony-cronos-cpld.c line 548
Quoted 6 lines
drivers/mfd/sony-cronos-cpld.c new file +6
-0+ chip->regmap =devm_regmap_init_i2c (i2c, config); +if (IS_ERR (chip->regmap)) { + ret =PTR_ERR (chip->regmap); +dev_err (chip->dev,"Failed to allocate register map: %d\n" , + ret); +return ret;
dev_err_probe()
drivers/mfd/sony-cronos-cpld.c line 555
Quoted 7 lines
drivers/mfd/sony-cronos-cpld.c new file +7
-0+ } + + ret =sony_cronos_get_device_type (chip); +if (ret) +return ret; + + ret = mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, cell,
Why not AUTO?
drivers/mfd/sony-cronos-cpld.c line 562
Quoted 7 lines
drivers/mfd/sony-cronos-cpld.c new file +7
-0+ cell_num, NULL, 0, NULL); +if (ret) { +dev_err (chip->dev,"Cannot register child devices\n" ); +return ret; + } + +/* Add sysfs */
This doesn't add anything.
drivers/mfd/sony-cronos-cpld.c line 575
Quoted 13 lines
drivers/mfd/sony-cronos-cpld.c new file +13
-0+ ret =sysfs_create_group (&chip->dev->kobj, &cronos_cpld_attr_group); +if (ret) +dev_err (chip->dev,"Failed to create sysfs entries\n" ); + +return ret; +} + +static void sony_cronos_i2c_remove (struct i2c_client *i2c) +{ +struct sony_cronos_cpld *chip =i2c_get_clientdata (i2c); + +sysfs_remove_group (&chip->dev->kobj, &cronos_cpld_attr_group); +mfd_remove_devices (chip->dev);
Use devm_* instead.
drivers/mfd/sony-cronos-cpld.c line 580
Quoted 5 lines
drivers/mfd/sony-cronos-cpld.c new file +5
-0+} + +static struct i2c_driver sony_cronos_i2c_driver = { + .driver = { + .name ="sony-cronos" ,
It's 'cpld' everywhere else. Why the change of heart?
drivers/mfd/sony-cronos-cpld.c line 586
Quoted 6 lines
drivers/mfd/sony-cronos-cpld.c new file +6
-0+ .of_match_table = of_match_ptr(cronos_cpld_dt_ids), + }, + .probe = sony_cronos_i2c_probe, + .remove = sony_cronos_i2c_remove, +}; +
Remove this line.
drivers/mfd/sony-cronos-cpld.c line 589
Quoted 3 lines
drivers/mfd/sony-cronos-cpld.c new file +3
-0+module_i2c_driver (sony_cronos_i2c_driver); + +MODULE_DESCRIPTION ("Core device driver for sony Cronos CPLDs" );
First mention of Core too.
"Sony"
drivers/mfd/sony-cronos-cpld.c line 590
Quoted 1 line
drivers/mfd/sony-cronos-cpld.c new file +1
-0+MODULE_AUTHOR ("Raptor Engineering, LLC <[email protected]>" );
Your 'support' department did not author this driver.
Quoted 92 lines
drivers/mfd/sony-cronos-cpld.c new file +1
-0+MODULE_LICENSE ("GPL" );include/linux/mfd/sony/cronos/core.h new file +17
-0@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2015-2017 Dialog Semiconductor +* Copyright (C) 2022 Raptor Engineering, LLC +*/ + +#ifndef __MFD_SONY_CRONOS_CORE_H__ +#define __MFD_SONY_CRONOS_CORE_H__ + +#include <linux/mfd/sony/cronos/registers.h> + +struct sony_cronos_cpld { +struct device *dev; +struct regmap *regmap; +}; + +#endif /* __MFD_SONY_CRONOS_H__ */ include/linux/mfd/sony/cronos/registers.h new file +59
-1@@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2015-2017 Dialog Semiconductor +* Copyright (C) 2022 Raptor Engineering, LLC +*/ + +#ifndef __SONY_CRONOS_H__ +#define __SONY_CRONOS_H__ + +#define CRONOS_CPLD_DEVICE_ID 0x0134 + +/* +* Registers and control masks / values +*/ + +#define CRONOS_CPLD_REVISION_HIGH_REG 0x73 +#define CRONOS_CPLD_REVISION_LOW_REG 0x72 +#define CRONOS_CPLD_DEVICE_ID_HIGH_REG 0x71 +#define CRONOS_CPLD_DEVICE_ID_LOW_REG 0x70 + +#define CRONOS_CPLD_BRIGHTNESS_RED_REG 0x17 +#define CRONOS_CPLD_BRIGHTNESS_GREEN_REG 0x18 +#define CRONOS_CPLD_BRIGHTNESS_BLUE_REG 0x19 + +#define CRONOS_CPLD_LEDS_BRIGHTNESS_SET_MASK 0x7F +#define CRONOS_LEDS_MAX_BRIGHTNESS 0x7F + +#define CRONOS_LEDS_SMC_STATUS_REG 0x10 +#define CRONOS_LEDS_SWITCH_STATUS_REG 0x11 + +#define CRONOS_LEDS_CCM1_STATUS_REG 0x15 +#define CRONOS_LEDS_CCM2_STATUS_REG 0x13 +#define CRONOS_LEDS_CCM3_STATUS_REG 0x12 +#define CRONOS_LEDS_CCM4_STATUS_REG 0x14 + +#define CRONOS_LEDS_CCM_POWER_REG 0x16 + +#define CRONOS_CPLD_UART_MUX_REG 0x0e +#define CRONOS_CPLD_SWITCH_BOOT_FLASH_SELECT_REG 0x00 +#define CRONOS_CPLD_SWITCH_RESET_CMD_REG 0x01 +#define CRONOS_CPLD_BMC_BOOT_FLASH_SELECT_REG 0x02 +#define CRONOS_CPLD_PAYLOAD_POWER_CTL_REG 0x0a +#define CRONOS_CPLD_BMC_MAC_LOW_REG 0x30 +#define CRONOS_CPLD_BMC_MAC_HIGH_REG 0x35 + +#define CRONOS_WDT_CLR_REG 0x03 +#define CRONOS_WDT_CTL_REG 0x0c + +#define CRONOS_CPLD_STATUS_2_REG 0x05 + +#define CRONOS_WDT_CLR_VAL 0xc3 +#define CRONOS_WDT_ENABLE_MASK 0x80 +#define CRONOS_WDT_ENABLE_VAL 0x80 +#define CRONOS_WDT_DISABLE_VAL 0x00 +#define CRONOS_WDT_TIMEOUT_MASK 0x07 +#define CRONOS_WDT_CTL_RESET_VAL 0x00 + + +#endif /* __SONY_CRONOS_H__ */ --2.30.2
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH v2 2/2] mfd: sie-cronos-cpld: Add driver for Sony Cronos CPLD
Quoted 50 lines · Lee Jones
Quoted 11 lines · Shawn Anastasio
From: Timothy Pearson <[email protected]>
The Sony Cronos Platform Controller CPLD is a multi-purpose platform
controller that provides both a watchdog timer and an LED controller for
the Sony Interactive Entertainment Cronos x86 server platform. As both
functions are provided by the same CPLD, a multi-function device is exposed as the parent of both functions.Quoted 8 lines
Signed-off-by Timothy Pearson <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>---
Changes in v2:
- Change SIE to Sony (SIE's parent company) to be more consistent with how other subsidiaries are treated in the kernel
- Fix build issue under !CONFIG_OF discovered by kernel test robotDoes this driver work without Device Tree?
Why can't you just drop the
of_match_ptr()?Quoted 24 lines
by guarding definition of
cronos_cpld_dt_idsas is done in other
drivers.MAINTAINERS | 7 + drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/sony-cronos-cpld.c | 591
++++++++++++++++++++++
include/linux/mfd/sony/cronos/core.h | 17 +include/linux/mfd/sony/cronos/registers.h| 59 +++6 files changed, 686 insertions(+)create mode 100644
drivers/mfd/sony-cronos-cpld.ccreate mode 100644include/linux/mfd/sony/cronos/core.hcreate mode 100644include/linux/mfd/sony/cronos/registers.hMAINTAINERS +0
-0@@ -19932,6 +19932,13 @@ S: MaintainedF: drivers/ssb/
F: include/linux/ssb/
Quoted 6 lines
MAINTAINERS S: Maintained · line 19936
Quoted 2 lines
MAINTAINERS +2
-0+SONY CRONOS CPLD DRIVER +M: Georgy Yakovlev <[email protected]>Are they aware of this?
They do not appear to be in the submission path.
Hello,
I'm aware, just watching and learning.
Quoted 2 lines
Quoted 2 lines
+S: Maintained
<rest snipped>