// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2006 Juergen Beisert, Pengutronix * Copyright (C) 2008 Guennadi Liakhovetski, Pengutronix * Copyright (C) 2009 Wolfram Sang, Pengutronix * * The Maxim MAX7300/1 device is an I2C/SPI driven GPIO expander. There are * 28 GPIOs. 8 of them can trigger an interrupt. See datasheet for more * details * Note: * - DIN must be stable at the rising edge of clock. * - when writing: * - always clock in 16 clocks at once * - at DIN: D15 first, D0 last * - D0..D7 = databyte, D8..D14 = commandbyte * - D15 = low -> write command * - when reading * - always clock in 16 clocks at once * - at DIN: D15 first, D0 last * - D0..D7 = dummy, D8..D14 = register address * - D15 = high -> read command * - raise CS and assert it again * - always clock in 16 clocks at once * - at DOUT: D15 first, D0 last * - D0..D7 contains the data from the first cycle * * The driver exports a standard gpiochip interface */ #include <linux/module.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/mutex.h> #include <linux/spi/max7301.h> #include <linux/gpio/driver.h> #include <linux/slab.h> /* * Pin configurations, see MAX7301 datasheet page 6 */ #define PIN_CONFIG_MASK … #define PIN_CONFIG_IN_PULLUP … #define PIN_CONFIG_IN_WO_PULLUP … #define PIN_CONFIG_OUT … #define PIN_NUMBER … static int max7301_direction_input(struct gpio_chip *chip, unsigned offset) { … } static int __max7301_set(struct max7301 *ts, unsigned offset, int value) { … } static int max7301_direction_output(struct gpio_chip *chip, unsigned offset, int value) { … } static int max7301_get(struct gpio_chip *chip, unsigned offset) { … } static void max7301_set(struct gpio_chip *chip, unsigned offset, int value) { … } int __max730x_probe(struct max7301 *ts) { … } EXPORT_SYMBOL_GPL(…); void __max730x_remove(struct device *dev) { … } EXPORT_SYMBOL_GPL(…); MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; MODULE_DESCRIPTION(…) …;