Lines Matching refs:lgpio
45 static inline void loongson_commit_direction(struct loongson_gpio_chip *lgpio, unsigned int pin, in loongson_commit_direction() argument
50 writeb(bval, lgpio->reg_base + lgpio->chip_data->conf_offset + pin); in loongson_commit_direction()
53 static void loongson_commit_level(struct loongson_gpio_chip *lgpio, unsigned int pin, int high) in loongson_commit_level() argument
57 writeb(bval, lgpio->reg_base + lgpio->chip_data->out_offset + pin); in loongson_commit_level()
63 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_direction_input() local
65 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_direction_input()
66 loongson_commit_direction(lgpio, pin, 1); in loongson_gpio_direction_input()
67 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_direction_input()
75 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_direction_output() local
77 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_direction_output()
78 loongson_commit_level(lgpio, pin, value); in loongson_gpio_direction_output()
79 loongson_commit_direction(lgpio, pin, 0); in loongson_gpio_direction_output()
80 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_direction_output()
89 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_get() local
91 bval = readb(lgpio->reg_base + lgpio->chip_data->in_offset + pin); in loongson_gpio_get()
100 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_get_direction() local
102 bval = readb(lgpio->reg_base + lgpio->chip_data->conf_offset + pin); in loongson_gpio_get_direction()
112 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_set() local
114 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_set()
115 loongson_commit_level(lgpio, pin, value); in loongson_gpio_set()
116 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_set()
123 struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); in loongson_gpio_to_irq() local
125 if (lgpio->chip_data->mode == BIT_CTRL_MODE) { in loongson_gpio_to_irq()
127 u = readl(lgpio->reg_base + lgpio->chip_data->inten_offset + (offset / 32) * 4); in loongson_gpio_to_irq()
129 writel(u, lgpio->reg_base + lgpio->chip_data->inten_offset + (offset / 32) * 4); in loongson_gpio_to_irq()
131 writeb(1, lgpio->reg_base + lgpio->chip_data->inten_offset + offset); in loongson_gpio_to_irq()
137 static int loongson_gpio_init(struct device *dev, struct loongson_gpio_chip *lgpio, in loongson_gpio_init() argument
143 lgpio->reg_base = reg_base; in loongson_gpio_init()
144 if (lgpio->chip_data->mode == BIT_CTRL_MODE) { in loongson_gpio_init()
145 ret = bgpio_init(&lgpio->chip, dev, 8, in loongson_gpio_init()
146 lgpio->reg_base + lgpio->chip_data->in_offset, in loongson_gpio_init()
147 lgpio->reg_base + lgpio->chip_data->out_offset, in loongson_gpio_init()
149 lgpio->reg_base + lgpio->chip_data->conf_offset, in loongson_gpio_init()
156 lgpio->chip.direction_input = loongson_gpio_direction_input; in loongson_gpio_init()
157 lgpio->chip.get = loongson_gpio_get; in loongson_gpio_init()
158 lgpio->chip.get_direction = loongson_gpio_get_direction; in loongson_gpio_init()
159 lgpio->chip.direction_output = loongson_gpio_direction_output; in loongson_gpio_init()
160 lgpio->chip.set = loongson_gpio_set; in loongson_gpio_init()
161 lgpio->chip.parent = dev; in loongson_gpio_init()
163 lgpio->chip.ngpio = ngpios; in loongson_gpio_init()
164 spin_lock_init(&lgpio->lock); in loongson_gpio_init()
167 lgpio->chip.label = lgpio->chip_data->label; in loongson_gpio_init()
168 lgpio->chip.can_sleep = false; in loongson_gpio_init()
169 if (lgpio->chip_data->inten_offset) in loongson_gpio_init()
170 lgpio->chip.to_irq = loongson_gpio_to_irq; in loongson_gpio_init()
172 return devm_gpiochip_add_data(dev, &lgpio->chip, lgpio); in loongson_gpio_init()
178 struct loongson_gpio_chip *lgpio; in loongson_gpio_probe() local
181 lgpio = devm_kzalloc(dev, sizeof(*lgpio), GFP_KERNEL); in loongson_gpio_probe()
182 if (!lgpio) in loongson_gpio_probe()
185 lgpio->chip_data = device_get_match_data(dev); in loongson_gpio_probe()
191 return loongson_gpio_init(dev, lgpio, reg_base); in loongson_gpio_probe()