Lines Matching +full:beeper +full:- +full:hz
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for PC-speaker like devices found on various Sparc systems.
19 MODULE_DESCRIPTION("Sparc Speaker beeper driver");
45 u32 val, clock_freq = info->clock_freq; in bbc_count_to_reg()
58 for (i = 19; i >= 11; i--) { in bbc_count_to_reg()
69 struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent); in bbc_spkr_event()
70 struct bbc_beep_info *info = &state->u.bbc; in bbc_spkr_event()
75 return -1; in bbc_spkr_event()
80 default: return -1; in bbc_spkr_event()
88 spin_lock_irqsave(&state->lock, flags); in bbc_spkr_event()
91 sbus_writeb(0x01, info->regs + 0); in bbc_spkr_event()
92 sbus_writeb(0x00, info->regs + 2); in bbc_spkr_event()
93 sbus_writeb((count >> 16) & 0xff, info->regs + 3); in bbc_spkr_event()
94 sbus_writeb((count >> 8) & 0xff, info->regs + 4); in bbc_spkr_event()
95 sbus_writeb(0x00, info->regs + 5); in bbc_spkr_event()
97 sbus_writeb(0x00, info->regs + 0); in bbc_spkr_event()
100 spin_unlock_irqrestore(&state->lock, flags); in bbc_spkr_event()
107 struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent); in grover_spkr_event()
108 struct grover_beep_info *info = &state->u.grover; in grover_spkr_event()
113 return -1; in grover_spkr_event()
118 default: return -1; in grover_spkr_event()
124 spin_lock_irqsave(&state->lock, flags); in grover_spkr_event()
128 sbus_writeb(sbus_readb(info->enable_reg) | 3, info->enable_reg); in grover_spkr_event()
130 sbus_writeb(0xB6, info->freq_regs + 1); in grover_spkr_event()
131 /* select desired HZ */ in grover_spkr_event()
132 sbus_writeb(count & 0xff, info->freq_regs + 0); in grover_spkr_event()
133 sbus_writeb((count >> 8) & 0xff, info->freq_regs + 0); in grover_spkr_event()
136 sbus_writeb(sbus_readb(info->enable_reg) & 0xFC, info->enable_reg); in grover_spkr_event()
139 spin_unlock_irqrestore(&state->lock, flags); in grover_spkr_event()
152 return -ENOMEM; in sparcspkr_probe()
154 input_dev->name = state->name; in sparcspkr_probe()
155 input_dev->phys = "sparc/input0"; in sparcspkr_probe()
156 input_dev->id.bustype = BUS_ISA; in sparcspkr_probe()
157 input_dev->id.vendor = 0x001f; in sparcspkr_probe()
158 input_dev->id.product = 0x0001; in sparcspkr_probe()
159 input_dev->id.version = 0x0100; in sparcspkr_probe()
160 input_dev->dev.parent = dev; in sparcspkr_probe()
162 input_dev->evbit[0] = BIT_MASK(EV_SND); in sparcspkr_probe()
163 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); in sparcspkr_probe()
165 input_dev->event = state->event; in sparcspkr_probe()
173 state->input_dev = input_dev; in sparcspkr_probe()
181 struct input_dev *input_dev = state->input_dev; in sparcspkr_shutdown()
184 state->event(input_dev, EV_SND, SND_BELL, 0); in sparcspkr_shutdown()
192 int err = -ENOMEM; in bbc_beep_probe()
198 state->name = "Sparc BBC Speaker"; in bbc_beep_probe()
199 state->event = bbc_spkr_event; in bbc_beep_probe()
200 spin_lock_init(&state->lock); in bbc_beep_probe()
203 err = -ENODEV; in bbc_beep_probe()
207 info = &state->u.bbc; in bbc_beep_probe()
208 info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0); in bbc_beep_probe()
210 if (!info->clock_freq) in bbc_beep_probe()
213 info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep"); in bbc_beep_probe()
214 if (!info->regs) in bbc_beep_probe()
219 err = sparcspkr_probe(&op->dev); in bbc_beep_probe()
226 of_iounmap(&op->resource[0], info->regs, 6); in bbc_beep_probe()
237 struct input_dev *input_dev = state->input_dev; in bbc_remove()
238 struct bbc_beep_info *info = &state->u.bbc; in bbc_remove()
241 state->event(input_dev, EV_SND, SND_BELL, 0); in bbc_remove()
245 of_iounmap(&op->resource[0], info->regs, 6); in bbc_remove()
253 .compatible = "SUNW,bbc-beep",
273 int err = -ENOMEM; in grover_beep_probe()
279 state->name = "Sparc Grover Speaker"; in grover_beep_probe()
280 state->event = grover_spkr_event; in grover_beep_probe()
281 spin_lock_init(&state->lock); in grover_beep_probe()
283 info = &state->u.grover; in grover_beep_probe()
284 info->freq_regs = of_ioremap(&op->resource[2], 0, 2, "grover beep freq"); in grover_beep_probe()
285 if (!info->freq_regs) in grover_beep_probe()
288 info->enable_reg = of_ioremap(&op->resource[3], 0, 1, "grover beep enable"); in grover_beep_probe()
289 if (!info->enable_reg) in grover_beep_probe()
294 err = sparcspkr_probe(&op->dev); in grover_beep_probe()
301 of_iounmap(&op->resource[3], info->enable_reg, 1); in grover_beep_probe()
304 of_iounmap(&op->resource[2], info->freq_regs, 2); in grover_beep_probe()
314 struct grover_beep_info *info = &state->u.grover; in grover_remove()
315 struct input_dev *input_dev = state->input_dev; in grover_remove()
318 state->event(input_dev, EV_SND, SND_BELL, 0); in grover_remove()
322 of_iounmap(&op->resource[3], info->enable_reg, 1); in grover_remove()
323 of_iounmap(&op->resource[2], info->freq_regs, 2); in grover_remove()
331 .compatible = "SUNW,smbus-beep",