Lines Matching refs:lgpio
44 static inline void loongson_commit_direction(struct loongson_gpio_chip *lgpio, unsigned int pin, in loongson_commit_direction() argument
49 writeb(bval, lgpio->reg_base + lgpio->chip_data->conf_offset + pin); in loongson_commit_direction()
52 static void loongson_commit_level(struct loongson_gpio_chip *lgpio, unsigned int pin, int high) in loongson_commit_level() argument
56 writeb(bval, lgpio->reg_base + lgpio->chip_data->out_offset + pin); in loongson_commit_level()
62 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_direction_input() local
64 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_direction_input()
65 loongson_commit_direction(lgpio, pin, 1); in loongson_gpio_direction_input()
66 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_direction_input()
74 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_direction_output() local
76 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_direction_output()
77 loongson_commit_level(lgpio, pin, value); in loongson_gpio_direction_output()
78 loongson_commit_direction(lgpio, pin, 0); in loongson_gpio_direction_output()
79 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_direction_output()
88 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_get() local
90 bval = readb(lgpio->reg_base + lgpio->chip_data->in_offset + pin); in loongson_gpio_get()
99 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_get_direction() local
101 bval = readb(lgpio->reg_base + lgpio->chip_data->conf_offset + pin); in loongson_gpio_get_direction()
111 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_set() local
113 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_set()
114 loongson_commit_level(lgpio, pin, value); in loongson_gpio_set()
115 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_set()
125 static int loongson_gpio_init(struct device *dev, struct loongson_gpio_chip *lgpio, in loongson_gpio_init() argument
131 lgpio->reg_base = reg_base; in loongson_gpio_init()
133 if (lgpio->chip_data->mode == BIT_CTRL_MODE) { in loongson_gpio_init()
134 ret = bgpio_init(&lgpio->chip, dev, 8, in loongson_gpio_init()
135 lgpio->reg_base + lgpio->chip_data->in_offset, in loongson_gpio_init()
136 lgpio->reg_base + lgpio->chip_data->out_offset, in loongson_gpio_init()
138 lgpio->reg_base + lgpio->chip_data->conf_offset, in loongson_gpio_init()
145 lgpio->chip.direction_input = loongson_gpio_direction_input; in loongson_gpio_init()
146 lgpio->chip.get = loongson_gpio_get; in loongson_gpio_init()
147 lgpio->chip.get_direction = loongson_gpio_get_direction; in loongson_gpio_init()
148 lgpio->chip.direction_output = loongson_gpio_direction_output; in loongson_gpio_init()
149 lgpio->chip.set = loongson_gpio_set; in loongson_gpio_init()
150 lgpio->chip.parent = dev; in loongson_gpio_init()
151 spin_lock_init(&lgpio->lock); in loongson_gpio_init()
156 lgpio->chip.can_sleep = 0; in loongson_gpio_init()
157 lgpio->chip.ngpio = ngpios; in loongson_gpio_init()
158 lgpio->chip.label = lgpio->chip_data->label; in loongson_gpio_init()
159 lgpio->chip.to_irq = loongson_gpio_to_irq; in loongson_gpio_init()
161 return devm_gpiochip_add_data(dev, &lgpio->chip, lgpio); in loongson_gpio_init()
167 struct loongson_gpio_chip *lgpio; in loongson_gpio_probe() local
171 lgpio = devm_kzalloc(dev, sizeof(*lgpio), GFP_KERNEL); in loongson_gpio_probe()
172 if (!lgpio) in loongson_gpio_probe()
175 lgpio->chip_data = device_get_match_data(dev); in loongson_gpio_probe()
181 return loongson_gpio_init(dev, lgpio, np, reg_base); in loongson_gpio_probe()