Lines Matching +full:loongson +full:- +full:1 +full:c

1 // SPDX-License-Identifier: GPL-2.0+
3 * Loongson GPIO Support
5 * Copyright (C) 2022-2023 Loongson Technology Corporation Limited
48 u8 bval = input ? 1 : 0; in loongson_commit_direction()
50 writeb(bval, lgpio->reg_base + lgpio->chip_data->conf_offset + pin); in loongson_commit_direction()
55 u8 bval = high ? 1 : 0; in loongson_commit_level()
57 writeb(bval, lgpio->reg_base + lgpio->chip_data->out_offset + pin); in loongson_commit_level()
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()
77 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_direction_output()
80 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_direction_output()
91 bval = readb(lgpio->reg_base + lgpio->chip_data->in_offset + pin); in loongson_gpio_get()
92 val = bval & 1; in loongson_gpio_get()
102 bval = readb(lgpio->reg_base + lgpio->chip_data->conf_offset + pin); in loongson_gpio_get_direction()
103 if (bval & 1) in loongson_gpio_get_direction()
114 spin_lock_irqsave(&lgpio->lock, flags); in loongson_gpio_set()
116 spin_unlock_irqrestore(&lgpio->lock, flags); in loongson_gpio_set()
122 struct platform_device *pdev = to_platform_device(chip->parent); in loongson_gpio_to_irq()
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()
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()
179 struct device *dev = &pdev->dev; in loongson_gpio_probe()
183 return -ENOMEM; in loongson_gpio_probe()
185 lgpio->chip_data = device_get_match_data(dev); in loongson_gpio_probe()
263 .compatible = "loongson,ls2k-gpio",
267 .compatible = "loongson,ls2k0500-gpio0",
271 .compatible = "loongson,ls2k0500-gpio1",
275 .compatible = "loongson,ls2k2000-gpio0",
279 .compatible = "loongson,ls2k2000-gpio1",
283 .compatible = "loongson,ls2k2000-gpio2",
287 .compatible = "loongson,ls3a5000-gpio",
291 .compatible = "loongson,ls7a-gpio",
325 .name = "loongson-gpio",
338 MODULE_DESCRIPTION("Loongson gpio driver");