aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/pinctrl/sophgo/pinctrl-cv18xx.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pinctrl/sophgo/pinctrl-cv18xx.h')
-rw-r--r--drivers/pinctrl/sophgo/pinctrl-cv18xx.h66
1 files changed, 25 insertions, 41 deletions
diff --git a/drivers/pinctrl/sophgo/pinctrl-cv18xx.h b/drivers/pinctrl/sophgo/pinctrl-cv18xx.h
index 1a9998abb3b7..759c0e604acf 100644
--- a/drivers/pinctrl/sophgo/pinctrl-cv18xx.h
+++ b/drivers/pinctrl/sophgo/pinctrl-cv18xx.h
@@ -8,13 +8,14 @@
#include <linux/bits.h>
#include <linux/bitfield.h>
-#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf.h>
+#include "pinctrl-sophgo.h"
+
enum cv1800_pin_io_type {
IO_TYPE_1V8_ONLY = 0,
IO_TYPE_1V8_OR_3V3 = 1,
@@ -49,58 +50,37 @@ struct cv1800_pinconf {
#define CV1800_PIN_FLAG_IO_TYPE(type) \
FIELD_PREP_CONST(CV1800_PIN_IO_TYPE, type)
struct cv1800_pin {
- u16 pin;
- u16 flags;
+ struct sophgo_pin pin;
u8 power_domain;
struct cv1800_pinmux mux;
struct cv1800_pinmux2 mux2;
struct cv1800_pinconf conf;
};
+#define sophgo_to_cv1800_pin(_pin) \
+ container_of((_pin), struct cv1800_pin, pin)
+
#define PIN_POWER_STATE_1V8 1800
#define PIN_POWER_STATE_3V3 3300
-/**
- * struct cv1800_vddio_cfg_ops - pin vddio operations
- *
- * @get_pull_up: get resistorĀ for pull up;
- * @get_pull_down: get resistorĀ for pull down.
- * @get_oc_map: get mapping for typical low level output current value to
- * register value map.
- * @get_schmitt_map: get mapping for register value to typical schmitt
- * threshold.
- */
-struct cv1800_vddio_cfg_ops {
- int (*get_pull_up)(struct cv1800_pin *pin, const u32 *psmap);
- int (*get_pull_down)(struct cv1800_pin *pin, const u32 *psmap);
- int (*get_oc_map)(struct cv1800_pin *pin, const u32 *psmap,
- const u32 **map);
- int (*get_schmitt_map)(struct cv1800_pin *pin, const u32 *psmap,
- const u32 **map);
-};
-
-struct cv1800_pinctrl_data {
- const struct pinctrl_pin_desc *pins;
- const struct cv1800_pin *pindata;
- const char * const *pdnames;
- const struct cv1800_vddio_cfg_ops *vddio_ops;
- u16 npins;
- u16 npd;
-};
-
-static inline enum cv1800_pin_io_type cv1800_pin_io_type(struct cv1800_pin *pin)
+static inline enum cv1800_pin_io_type cv1800_pin_io_type(const struct cv1800_pin *pin)
{
- return FIELD_GET(CV1800_PIN_IO_TYPE, pin->flags);
+ return FIELD_GET(CV1800_PIN_IO_TYPE, pin->pin.flags);
};
-int cv1800_pinctrl_probe(struct platform_device *pdev);
+extern const struct pinctrl_ops cv1800_pctrl_ops;
+extern const struct pinmux_ops cv1800_pmx_ops;
+extern const struct pinconf_ops cv1800_pconf_ops;
+extern const struct sophgo_cfg_ops cv1800_cfg_ops;
#define CV1800_FUNC_PIN(_id, _power_domain, _type, \
_mux_area, _mux_offset, _mux_func_max) \
{ \
- .pin = (_id), \
+ .pin = { \
+ .id = (_id), \
+ .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \
+ }, \
.power_domain = (_power_domain), \
- .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \
.mux = { \
.area = (_mux_area), \
.offset = (_mux_offset), \
@@ -112,9 +92,11 @@ int cv1800_pinctrl_probe(struct platform_device *pdev);
_mux_area, _mux_offset, _mux_func_max, \
_conf_area, _conf_offset) \
{ \
- .pin = (_id), \
+ .pin = { \
+ .id = (_id), \
+ .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \
+ }, \
.power_domain = (_power_domain), \
- .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \
.mux = { \
.area = (_mux_area), \
.offset = (_mux_offset), \
@@ -132,10 +114,12 @@ int cv1800_pinctrl_probe(struct platform_device *pdev);
_mux2_func_max, \
_conf_area, _conf_offset) \
{ \
- .pin = (_id), \
+ .pin = { \
+ .id = (_id), \
+ .flags = CV1800_PIN_FLAG_IO_TYPE(_type) | \
+ CV1800_PIN_HAVE_MUX2, \
+ }, \
.power_domain = (_power_domain), \
- .flags = CV1800_PIN_FLAG_IO_TYPE(_type) | \
- CV1800_PIN_HAVE_MUX2, \
.mux = { \
.area = (_mux_area), \
.offset = (_mux_offset), \