linux/drivers/input/keyboard/lm8323.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * drivers/i2c/chips/lm8323.c
 *
 * Copyright (C) 2007-2009 Nokia Corporation
 *
 * Written by Daniel Stone <[email protected]>
 *            Timo O. Karjalainen <[email protected]>
 *
 * Updated by Felipe Balbi <[email protected]>
 */

#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/leds.h>
#include <linux/platform_data/lm8323.h>
#include <linux/pm.h>
#include <linux/slab.h>

/* Commands to send to the chip. */
#define LM8323_CMD_READ_ID
#define LM8323_CMD_WRITE_CFG
#define LM8323_CMD_READ_INT
#define LM8323_CMD_RESET
#define LM8323_CMD_WRITE_PORT_SEL
#define LM8323_CMD_WRITE_PORT_STATE
#define LM8323_CMD_READ_PORT_SEL
#define LM8323_CMD_READ_PORT_STATE
#define LM8323_CMD_READ_FIFO
#define LM8323_CMD_RPT_READ_FIFO
#define LM8323_CMD_SET_ACTIVE
#define LM8323_CMD_READ_ERR
#define LM8323_CMD_READ_ROTATOR
#define LM8323_CMD_SET_DEBOUNCE
#define LM8323_CMD_SET_KEY_SIZE
#define LM8323_CMD_READ_KEY_SIZE
#define LM8323_CMD_READ_CFG
#define LM8323_CMD_WRITE_CLOCK
#define LM8323_CMD_READ_CLOCK
#define LM8323_CMD_PWM_WRITE
#define LM8323_CMD_START_PWM
#define LM8323_CMD_STOP_PWM

/* Interrupt status. */
#define INT_KEYPAD
#define INT_ROTATOR
#define INT_ERROR
#define INT_NOINIT
#define INT_PWM1
#define INT_PWM2
#define INT_PWM3

/* Errors (signalled by INT_ERROR, read with CMD_READ_ERR). */
#define ERR_BADPAR
#define ERR_CMDUNK
#define ERR_KEYOVR
#define ERR_FIFOOVER

/* Configuration keys (CMD_{WRITE,READ}_CFG). */
#define CFG_MUX1SEL
#define CFG_MUX1EN
#define CFG_MUX2SEL
#define CFG_MUX2EN
#define CFG_PSIZE
#define CFG_ROTEN

/* Clock settings (CMD_{WRITE,READ}_CLOCK). */
#define CLK_RCPWM_INTERNAL
#define CLK_RCPWM_EXTERNAL
#define CLK_SLOWCLKEN
#define CLK_SLOWCLKOUT

/* The possible addresses corresponding to CONFIG1 and CONFIG2 pin wirings. */
#define LM8323_I2C_ADDR00
#define LM8323_I2C_ADDR01
#define LM8323_I2C_ADDR10
#define LM8323_I2C_ADDR11

/* Key event fifo length */
#define LM8323_FIFO_LEN

/* Commands for PWM engine; feed in with PWM_WRITE. */
/* Load ramp counter from duty cycle field (range 0 - 0xff). */
#define PWM_SET(v)
/* Go to start of script. */
#define PWM_GOTOSTART
/*
 * Stop engine (generates interrupt).  If reset is 1, clear the program
 * counter, else leave it.
 */
#define PWM_END(reset)
/*
 * Ramp.  If s is 1, divide clock by 512, else divide clock by 16.
 * Take t clock scales (up to 63) per step, for n steps (up to 126).
 * If u is set, ramp up, else ramp down.
 */
#define PWM_RAMP(s, t, n, u)
/*
 * Loop (i.e. jump back to pos) for a given number of iterations (up to 63).
 * If cnt is zero, execute until PWM_END is encountered.
 */
#define PWM_LOOP(cnt, pos)
/*
 * Wait for trigger.  Argument is a mask of channels, shifted by the channel
 * number, e.g. 0xa for channels 3 and 1.  Note that channels are numbered
 * from 1, not 0.
 */
#define PWM_WAIT_TRIG(chans)
/* Send trigger.  Argument is same as PWM_WAIT_TRIG. */
#define PWM_SEND_TRIG(chans)

struct lm8323_pwm {};

struct lm8323_chip {};

#define client_to_lm8323(c)
#define dev_to_lm8323(d)
#define cdev_to_pwm(c)
#define work_to_pwm(w)

#define LM8323_MAX_DATA

/*
 * To write, we just access the chip's address in write mode, and dump the
 * command and data out on the bus.  The command byte and data are taken as
 * sequential u8s out of varargs, to a maximum of LM8323_MAX_DATA.
 */
static int lm8323_write(struct lm8323_chip *lm, int len, ...)
{}

/*
 * To read, we first send the command byte to the chip and end the transaction,
 * then access the chip in read mode, at which point it will send the data.
 */
static int lm8323_read(struct lm8323_chip *lm, u8 cmd, u8 *buf, int len)
{}

/*
 * Set the chip active time (idle time before it enters halt).
 */
static void lm8323_set_active_time(struct lm8323_chip *lm, int time)
{}

/*
 * The signals are AT-style: the low 7 bits are the keycode, and the top
 * bit indicates the state (1 for down, 0 for up).
 */
static inline u8 lm8323_whichkey(u8 event)
{}

static inline int lm8323_ispress(u8 event)
{}

static void process_keys(struct lm8323_chip *lm)
{}

static void lm8323_process_error(struct lm8323_chip *lm)
{}

static void lm8323_reset(struct lm8323_chip *lm)
{}

static int lm8323_configure(struct lm8323_chip *lm)
{}

static void pwm_done(struct lm8323_pwm *pwm)
{}

/*
 * Bottom half: handle the interrupt by posting key events, or dealing with
 * errors appropriately.
 */
static irqreturn_t lm8323_irq(int irq, void *_lm)
{}

/*
 * Read the chip ID.
 */
static int lm8323_read_id(struct lm8323_chip *lm, u8 *buf)
{}

static void lm8323_write_pwm_one(struct lm8323_pwm *pwm, int pos, u16 cmd)
{}

/*
 * Write a script into a given PWM engine, concluding with PWM_END.
 * If 'kill' is nonzero, the engine will be shut down at the end
 * of the script, producing a zero output. Otherwise the engine
 * will be kept running at the final PWM level indefinitely.
 */
static void lm8323_write_pwm(struct lm8323_pwm *pwm, int kill,
			     int len, const u16 *cmds)
{}

static void lm8323_pwm_work(struct work_struct *work)
{}

static void lm8323_pwm_set_brightness(struct led_classdev *led_cdev,
				      enum led_brightness brightness)
{}

static ssize_t lm8323_pwm_show_time(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t lm8323_pwm_store_time(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}
static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time);

static struct attribute *lm8323_pwm_attrs[] =;
ATTRIBUTE_GROUPS();

static int init_pwm(struct lm8323_chip *lm, int id, struct device *dev,
		    const char *name)
{}

static ssize_t lm8323_show_disable(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static ssize_t lm8323_set_disable(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}
static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable);

static struct attribute *lm8323_attrs[] =;
ATTRIBUTE_GROUPS();

static int lm8323_probe(struct i2c_client *client)
{}

/*
 * We don't need to explicitly suspend the chip, as it already switches off
 * when there's no activity.
 */
static int lm8323_suspend(struct device *dev)
{}

static int lm8323_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(lm8323_pm_ops, lm8323_suspend, lm8323_resume);

static const struct i2c_device_id lm8323_id[] =;

static struct i2c_driver lm8323_i2c_driver =;
MODULE_DEVICE_TABLE(i2c, lm8323_id);

module_i2c_driver();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();