#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/mux/driver.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/property.h>
struct gpio_descs *gpios;
static int mux_gpio_set(struct mux_control *mux, int state)
struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip);
DECLARE_BITMAP(values, BITS_PER_TYPE(state));
gpiod_set_array_value_cansleep(mux_gpio->gpios->ndescs,
mux_gpio->gpios->info, values);
static const struct mux_control_ops mux_gpio_ops = {
static const struct of_device_id mux_gpio_dt_ids[] = {
{ .compatible = "gpio-mux", },
MODULE_DEVICE_TABLE(of, mux_gpio_dt_ids);
static int mux_gpio_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct mux_chip *mux_chip;
struct mux_gpio *mux_gpio;
pins = gpiod_count(dev, "mux");
mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*mux_gpio));
return PTR_ERR(mux_chip);
mux_gpio = mux_chip_priv(mux_chip);