From 23fa18eaa71266feff7ba8d83022d9e1cc83c65a Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 10 May 2024 07:42:03 +0000
Subject: [PATCH] disable pwm7
---
kernel/include/linux/pwm.h | 248 +++++++++++++-----------------------------------
1 files changed, 69 insertions(+), 179 deletions(-)
diff --git a/kernel/include/linux/pwm.h b/kernel/include/linux/pwm.h
index 88c16c5..50d44f7 100644
--- a/kernel/include/linux/pwm.h
+++ b/kernel/include/linux/pwm.h
@@ -5,6 +5,7 @@
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/android_kabi.h>
struct pwm_capture;
struct seq_file;
@@ -59,18 +60,6 @@
PWM_OUTPUT_MODULATED = 1 << 1,
};
-/**
- * struct pwm_output_pattern - PWM duty pattern for MODULATED duty type
- * @duty_pattern: PWM duty cycles in the pattern for duty modulation
- * @num_entries: number of entries in the pattern
- * @cycles_per_duty: number of PWM period cycles an entry stays at
- */
-struct pwm_output_pattern {
- u64 *duty_pattern;
- unsigned int num_entries;
- u64 cycles_per_duty;
-};
-
/*
* struct pwm_state - state of a PWM channel
* @period: PWM period (in nanoseconds)
@@ -83,9 +72,10 @@
u64 duty_cycle;
enum pwm_polarity polarity;
enum pwm_output_type output_type;
- struct pwm_output_pattern *output_pattern;
#ifdef CONFIG_PWM_ROCKCHIP_ONESHOT
u64 oneshot_count;
+ u32 oneshot_repeat;
+ u64 duty_offset;
#endif /* CONFIG_PWM_ROCKCHIP_ONESHOT */
bool enabled;
};
@@ -99,7 +89,8 @@
* @chip: PWM chip providing this PWM device
* @chip_data: chip-private data associated with the PWM device
* @args: PWM arguments
- * @state: curent PWM channel state
+ * @state: last applied state
+ * @last: last implemented state (for PWM_DEBUG)
*/
struct pwm_device {
const char *label;
@@ -111,6 +102,9 @@
struct pwm_args args;
struct pwm_state state;
+ struct pwm_state last;
+
+ ANDROID_KABI_RESERVE(1);
};
/**
@@ -133,31 +127,13 @@
return state.enabled;
}
-static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period)
+static inline void pwm_set_period(struct pwm_device *pwm, u64 period)
{
if (pwm)
pwm->state.period = period;
}
-static inline void pwm_set_period_extend(struct pwm_device *pwm, u64 period)
-{
- if (pwm)
- pwm->state.period = period;
-}
-
-static inline unsigned int pwm_get_period(const struct pwm_device *pwm)
-{
- struct pwm_state state;
-
- pwm_get_state(pwm, &state);
-
- if (state.period > UINT_MAX)
- pr_warn("PWM period %llu is truncated\n", state.period);
-
- return (unsigned int)state.period;
-}
-
-static inline u64 pwm_get_period_extend(const struct pwm_device *pwm)
+static inline u64 pwm_get_period(const struct pwm_device *pwm)
{
struct pwm_state state;
@@ -172,25 +148,7 @@
pwm->state.duty_cycle = duty;
}
-static inline void pwm_set_duty_cycle_extend(struct pwm_device *pwm, u64 duty)
-{
- if (pwm)
- pwm->state.duty_cycle = duty;
-}
-
-static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm)
-{
- struct pwm_state state;
-
- pwm_get_state(pwm, &state);
-
- if (state.duty_cycle > UINT_MAX)
- pr_warn("PWM duty cycle %llu is truncated\n", state.duty_cycle);
-
- return (unsigned int)state.duty_cycle;
-}
-
-static inline u64 pwm_get_duty_cycle_extend(const struct pwm_device *pwm)
+static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm)
{
struct pwm_state state;
@@ -216,16 +174,6 @@
pwm_get_state(pwm, &state);
return state.output_type;
-}
-
-static inline struct pwm_output_pattern *pwm_get_output_pattern(
- struct pwm_device *pwm)
-{
- struct pwm_state state;
-
- pwm_get_state(pwm, &state);
-
- return pwm->state.output_pattern ?: NULL;
}
static inline void pwm_get_args(const struct pwm_device *pwm,
@@ -326,79 +274,68 @@
* struct pwm_ops - PWM controller operations
* @request: optional hook for requesting a PWM
* @free: optional hook for freeing a PWM
- * @config: configure duty cycles and period length for this PWM
- * @config_extend: configure duty cycles and period length for this
- * PWM with u64 data type
- * @set_polarity: configure the polarity of this PWM
* @capture: capture and report PWM signal
- * @enable: enable PWM output toggling
- * @disable: disable PWM output toggling
- * @get_output_type_supported: get the supported output type
- * @set_output_type: set PWM output type
- * @set_output_pattern: set the pattern for the modulated output
- * @apply: atomically apply a new PWM config. The state argument
- * should be adjusted with the real hardware config (if the
- * approximate the period or duty_cycle value, state should
- * reflect it)
+ * @apply: atomically apply a new PWM config
* @get_state: get the current PWM state. This function is only
* called once per PWM device when the PWM chip is
* registered.
- * @dbg_show: optional routine to show contents in debugfs
+ * @get_output_type_supported: get the supported output type of this PWM
* @owner: helps prevent removal of modules exporting active PWMs
+ * @config: configure duty cycles and period length for this PWM
+ * @set_polarity: configure the polarity of this PWM
+ * @enable: enable PWM output toggling
+ * @disable: disable PWM output toggling
*/
struct pwm_ops {
int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
void (*free)(struct pwm_chip *chip, struct pwm_device *pwm);
- int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
- int duty_ns, int period_ns);
- int (*config_extend)(struct pwm_chip *chip, struct pwm_device *pwm,
- u64 duty_ns, u64 period_ns);
- int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
- enum pwm_polarity polarity);
int (*capture)(struct pwm_chip *chip, struct pwm_device *pwm,
struct pwm_capture *result, unsigned long timeout);
- int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
- void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
- int (*get_output_type_supported)(struct pwm_chip *chip,
- struct pwm_device *pwm);
- int (*set_output_type)(struct pwm_chip *chip, struct pwm_device *pwm,
- enum pwm_output_type output_type);
- int (*set_output_pattern)(struct pwm_chip *chip,
- struct pwm_device *pwm,
- struct pwm_output_pattern *output_pattern);
int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm,
- struct pwm_state *state);
+ const struct pwm_state *state);
void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
struct pwm_state *state);
-#ifdef CONFIG_DEBUG_FS
- void (*dbg_show)(struct pwm_chip *chip, struct seq_file *s);
-#endif
+ int (*get_output_type_supported)(struct pwm_chip *chip,
+ struct pwm_device *pwm);
struct module *owner;
+
+ /* Only used by legacy drivers */
+ int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns);
+ int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
+ enum pwm_polarity polarity);
+ int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
+ void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
+
+ ANDROID_KABI_RESERVE(1);
};
/**
* struct pwm_chip - abstract a PWM controller
* @dev: device providing the PWMs
- * @list: list node for internal use
* @ops: callbacks for this PWM controller
* @base: number of first PWM controlled by this chip
* @npwm: number of PWMs controlled by this chip
- * @pwms: array of PWM devices allocated by the framework
* @of_xlate: request a PWM device given a device tree PWM specifier
* @of_pwm_n_cells: number of cells expected in the device tree PWM specifier
+ * @list: list node for internal use
+ * @pwms: array of PWM devices allocated by the framework
*/
struct pwm_chip {
struct device *dev;
- struct list_head list;
const struct pwm_ops *ops;
int base;
unsigned int npwm;
- struct pwm_device *pwms;
-
struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
const struct of_phandle_args *args);
unsigned int of_pwm_n_cells;
+
+ /* only used internally by the PWM framework */
+ struct list_head list;
+ struct pwm_device *pwms;
+
+ ANDROID_KABI_RESERVE(1);
};
/**
@@ -407,30 +344,33 @@
* @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
*/
struct pwm_capture {
- u64 period;
- u64 duty_cycle;
+ unsigned int period;
+ unsigned int duty_cycle;
};
#if IS_ENABLED(CONFIG_PWM)
/* PWM user APIs */
struct pwm_device *pwm_request(int pwm_id, const char *label);
void pwm_free(struct pwm_device *pwm);
-int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state);
+int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state);
int pwm_adjust_config(struct pwm_device *pwm);
/**
- * pwm_output_type_support()
+ * pwm_get_output_type_supported() - obtain output type of a PWM device.
* @pwm: PWM device
*
- * Returns: output types supported by the PWM device
+ * Returns: output type supported by the PWM device
*/
static inline int pwm_get_output_type_supported(struct pwm_device *pwm)
{
- if (pwm->chip->ops->get_output_type_supported != NULL)
+ if (!pwm)
+ return -EINVAL;
+
+ if (pwm->chip->ops->get_output_type_supported)
return pwm->chip->ops->get_output_type_supported(pwm->chip,
- pwm);
- else
- return PWM_OUTPUT_FIXED;
+ pwm);
+
+ return PWM_OUTPUT_FIXED;
}
/**
@@ -458,67 +398,6 @@
state.duty_cycle = duty_ns;
state.period = period_ns;
- return pwm_apply_state(pwm, &state);
-}
-
-/**
- * pwm_config_extend() - change PWM period and duty length with u64 data type
- * @pwm: PWM device
- * @duty_ns: "on" time (in nanoseconds)
- * @period_ns: duration (in nanoseconds) of one cycle
- *
- * Returns: 0 on success or a negative error code on failure.
- */
-static inline int pwm_config_extend(struct pwm_device *pwm, u64 duty_ns,
- u64 period_ns)
-{
- struct pwm_state state;
-
- if (!pwm)
- return -EINVAL;
-
- pwm_get_state(pwm, &state);
- if (state.duty_cycle == duty_ns && state.period == period_ns)
- return 0;
-
- state.duty_cycle = duty_ns;
- state.period = period_ns;
- return pwm_apply_state(pwm, &state);
-}
-
-/**
- * pwm_set_polarity() - configure the polarity of a PWM signal
- * @pwm: PWM device
- * @polarity: new polarity of the PWM signal
- *
- * Note that the polarity cannot be configured while the PWM device is
- * enabled.
- *
- * Returns: 0 on success or a negative error code on failure.
- */
-static inline int pwm_set_polarity(struct pwm_device *pwm,
- enum pwm_polarity polarity)
-{
- struct pwm_state state;
-
- if (!pwm)
- return -EINVAL;
-
- pwm_get_state(pwm, &state);
- if (state.polarity == polarity)
- return 0;
-
- /*
- * Changing the polarity of a running PWM without adjusting the
- * dutycycle/period value is a bit risky (can introduce glitches).
- * Return -EBUSY in this case.
- * Note that this is allowed when using pwm_apply_state() because
- * the user specifies all the parameters.
- */
- if (state.enabled)
- return -EBUSY;
-
- state.polarity = polarity;
return pwm_apply_state(pwm, &state);
}
@@ -580,12 +459,16 @@
const struct of_phandle_args *args);
struct pwm_device *pwm_get(struct device *dev, const char *con_id);
-struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id);
+struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np,
+ const char *con_id);
void pwm_put(struct pwm_device *pwm);
struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
const char *con_id);
+struct pwm_device *devm_fwnode_pwm_get(struct device *dev,
+ struct fwnode_handle *fwnode,
+ const char *con_id);
void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
#else
static inline struct pwm_device *pwm_request(int pwm_id, const char *label)
@@ -608,6 +491,11 @@
return -ENOTSUPP;
}
+static inline int pwm_get_output_type_supported(struct pwm_device *pwm)
+{
+ return -EINVAL;
+}
+
static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
int period_ns)
{
@@ -619,12 +507,6 @@
unsigned long timeout)
{
return -EINVAL;
-}
-
-static inline int pwm_set_polarity(struct pwm_device *pwm,
- enum pwm_polarity polarity)
-{
- return -ENOTSUPP;
}
static inline int pwm_enable(struct pwm_device *pwm)
@@ -674,7 +556,8 @@
return ERR_PTR(-ENODEV);
}
-static inline struct pwm_device *of_pwm_get(struct device_node *np,
+static inline struct pwm_device *of_pwm_get(struct device *dev,
+ struct device_node *np,
const char *con_id)
{
return ERR_PTR(-ENODEV);
@@ -697,6 +580,13 @@
return ERR_PTR(-ENODEV);
}
+static inline struct pwm_device *
+devm_fwnode_pwm_get(struct device *dev, struct fwnode_handle *fwnode,
+ const char *con_id)
+{
+ return ERR_PTR(-ENODEV);
+}
+
static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
{
}
--
Gitblit v1.6.2