Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Driver for PC-speaker like devices found on various Sparc systems. |
| 3 | * |
| 4 | * Copyright (c) 2002 Vojtech Pavlik |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 5 | * Copyright (c) 2002, 2006, 2008 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/kernel.h> |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/input.h> |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 11 | #include <linux/of_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 16 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); |
Dmitry Torokhov | 76b7cdd | 2005-09-15 02:01:51 -0500 | [diff] [blame] | 17 | MODULE_DESCRIPTION("Sparc Speaker beeper driver"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | MODULE_LICENSE("GPL"); |
| 19 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 20 | struct grover_beep_info { |
| 21 | void __iomem *freq_regs; |
| 22 | void __iomem *enable_reg; |
| 23 | }; |
| 24 | |
| 25 | struct bbc_beep_info { |
| 26 | u32 clock_freq; |
| 27 | void __iomem *regs; |
| 28 | }; |
| 29 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 30 | struct sparcspkr_state { |
| 31 | const char *name; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 32 | int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); |
| 33 | spinlock_t lock; |
| 34 | struct input_dev *input_dev; |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 35 | union { |
| 36 | struct grover_beep_info grover; |
| 37 | struct bbc_beep_info bbc; |
| 38 | } u; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 39 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 41 | static u32 bbc_count_to_reg(struct bbc_beep_info *info, unsigned int count) |
| 42 | { |
| 43 | u32 val, clock_freq = info->clock_freq; |
| 44 | int i; |
| 45 | |
| 46 | if (!count) |
| 47 | return 0; |
| 48 | |
| 49 | if (count <= clock_freq >> 20) |
| 50 | return 1 << 18; |
| 51 | |
| 52 | if (count >= clock_freq >> 12) |
| 53 | return 1 << 10; |
| 54 | |
| 55 | val = 1 << 18; |
| 56 | for (i = 19; i >= 11; i--) { |
| 57 | val >>= 1; |
| 58 | if (count <= clock_freq >> i) |
| 59 | break; |
| 60 | } |
| 61 | |
| 62 | return val; |
| 63 | } |
| 64 | |
| 65 | static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Dmitry Torokhov | 293e639 | 2007-04-12 01:35:32 -0400 | [diff] [blame] | 67 | struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent); |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 68 | struct bbc_beep_info *info = &state->u.bbc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | unsigned int count = 0; |
| 70 | unsigned long flags; |
| 71 | |
| 72 | if (type != EV_SND) |
| 73 | return -1; |
| 74 | |
| 75 | switch (code) { |
| 76 | case SND_BELL: if (value) value = 1000; |
| 77 | case SND_TONE: break; |
| 78 | default: return -1; |
| 79 | } |
| 80 | |
| 81 | if (value > 20 && value < 32767) |
| 82 | count = 1193182 / value; |
| 83 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 84 | count = bbc_count_to_reg(info, count); |
| 85 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 86 | spin_lock_irqsave(&state->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 88 | if (count) { |
| 89 | outb(0x01, info->regs + 0); |
| 90 | outb(0x00, info->regs + 2); |
| 91 | outb((count >> 16) & 0xff, info->regs + 3); |
| 92 | outb((count >> 8) & 0xff, info->regs + 4); |
| 93 | outb(0x00, info->regs + 5); |
| 94 | } else { |
| 95 | outb(0x00, info->regs + 0); |
| 96 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 98 | spin_unlock_irqrestore(&state->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 103 | static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | { |
Dmitry Torokhov | 293e639 | 2007-04-12 01:35:32 -0400 | [diff] [blame] | 105 | struct sparcspkr_state *state = dev_get_drvdata(dev->dev.parent); |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 106 | struct grover_beep_info *info = &state->u.grover; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | unsigned int count = 0; |
| 108 | unsigned long flags; |
| 109 | |
| 110 | if (type != EV_SND) |
| 111 | return -1; |
| 112 | |
| 113 | switch (code) { |
| 114 | case SND_BELL: if (value) value = 1000; |
| 115 | case SND_TONE: break; |
| 116 | default: return -1; |
| 117 | } |
| 118 | |
| 119 | if (value > 20 && value < 32767) |
| 120 | count = 1193182 / value; |
| 121 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 122 | spin_lock_irqsave(&state->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
| 124 | if (count) { |
| 125 | /* enable counter 2 */ |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 126 | outb(inb(info->enable_reg) | 3, info->enable_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | /* set command for counter 2, 2 byte write */ |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 128 | outb(0xB6, info->freq_regs + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | /* select desired HZ */ |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 130 | outb(count & 0xff, info->freq_regs + 0); |
| 131 | outb((count >> 8) & 0xff, info->freq_regs + 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } else { |
| 133 | /* disable counter 2 */ |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 134 | outb(inb_p(info->enable_reg) & 0xFC, info->enable_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 137 | spin_unlock_irqrestore(&state->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 142 | static int __devinit sparcspkr_probe(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 144 | struct sparcspkr_state *state = dev_get_drvdata(dev); |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 145 | struct input_dev *input_dev; |
| 146 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 148 | input_dev = input_allocate_device(); |
| 149 | if (!input_dev) |
Dmitry Torokhov | 76b7cdd | 2005-09-15 02:01:51 -0500 | [diff] [blame] | 150 | return -ENOMEM; |
| 151 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 152 | input_dev->name = state->name; |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 153 | input_dev->phys = "sparc/input0"; |
| 154 | input_dev->id.bustype = BUS_ISA; |
| 155 | input_dev->id.vendor = 0x001f; |
| 156 | input_dev->id.product = 0x0001; |
| 157 | input_dev->id.version = 0x0100; |
Dmitry Torokhov | 293e639 | 2007-04-12 01:35:32 -0400 | [diff] [blame] | 158 | input_dev->dev.parent = dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 160 | input_dev->evbit[0] = BIT_MASK(EV_SND); |
| 161 | input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 163 | input_dev->event = state->event; |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 164 | |
| 165 | error = input_register_device(input_dev); |
| 166 | if (error) { |
| 167 | input_free_device(input_dev); |
| 168 | return error; |
| 169 | } |
| 170 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 171 | state->input_dev = input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | return 0; |
| 174 | } |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 175 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 176 | static int sparcspkr_shutdown(struct platform_device *dev) |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 177 | { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 178 | struct sparcspkr_state *state = dev_get_drvdata(&dev->dev); |
| 179 | struct input_dev *input_dev = state->input_dev; |
| 180 | |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 181 | /* turn off the speaker */ |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 182 | state->event(input_dev, EV_SND, SND_BELL, 0); |
| 183 | |
| 184 | return 0; |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 185 | } |
| 186 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 187 | static int __devinit bbc_beep_probe(struct platform_device *op, const struct of_device_id *match) |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 188 | { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 189 | struct sparcspkr_state *state; |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 190 | struct bbc_beep_info *info; |
| 191 | struct device_node *dp; |
| 192 | int err = -ENOMEM; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 193 | |
| 194 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
| 195 | if (!state) |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 196 | goto out_err; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 197 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 198 | state->name = "Sparc BBC Speaker"; |
| 199 | state->event = bbc_spkr_event; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 200 | spin_lock_init(&state->lock); |
| 201 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 202 | dp = of_find_node_by_path("/"); |
| 203 | err = -ENODEV; |
| 204 | if (!dp) |
| 205 | goto out_free; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 206 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 207 | info = &state->u.bbc; |
| 208 | info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0); |
| 209 | if (!info->clock_freq) |
| 210 | goto out_free; |
| 211 | |
| 212 | info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep"); |
| 213 | if (!info->regs) |
| 214 | goto out_free; |
| 215 | |
| 216 | dev_set_drvdata(&op->dev, state); |
| 217 | |
| 218 | err = sparcspkr_probe(&op->dev); |
| 219 | if (err) |
| 220 | goto out_clear_drvdata; |
| 221 | |
| 222 | return 0; |
| 223 | |
| 224 | out_clear_drvdata: |
| 225 | dev_set_drvdata(&op->dev, NULL); |
| 226 | of_iounmap(&op->resource[0], info->regs, 6); |
| 227 | |
| 228 | out_free: |
| 229 | kfree(state); |
| 230 | out_err: |
| 231 | return err; |
| 232 | } |
| 233 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 234 | static int __devexit bbc_remove(struct platform_device *op) |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 235 | { |
| 236 | struct sparcspkr_state *state = dev_get_drvdata(&op->dev); |
| 237 | struct input_dev *input_dev = state->input_dev; |
| 238 | struct bbc_beep_info *info = &state->u.bbc; |
| 239 | |
| 240 | /* turn off the speaker */ |
| 241 | state->event(input_dev, EV_SND, SND_BELL, 0); |
| 242 | |
| 243 | input_unregister_device(input_dev); |
| 244 | |
| 245 | of_iounmap(&op->resource[0], info->regs, 6); |
| 246 | |
| 247 | dev_set_drvdata(&op->dev, NULL); |
| 248 | kfree(state); |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 249 | |
| 250 | return 0; |
| 251 | } |
| 252 | |
David S. Miller | fd09831 | 2008-08-31 01:23:17 -0700 | [diff] [blame] | 253 | static const struct of_device_id bbc_beep_match[] = { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 254 | { |
| 255 | .name = "beep", |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 256 | .compatible = "SUNW,bbc-beep", |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 257 | }, |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 258 | {}, |
| 259 | }; |
| 260 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 261 | static struct of_platform_driver bbc_beep_driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 262 | .driver = { |
| 263 | .name = "bbcbeep", |
| 264 | .owner = THIS_MODULE, |
| 265 | .of_match_table = bbc_beep_match, |
| 266 | }, |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 267 | .probe = bbc_beep_probe, |
| 268 | .remove = __devexit_p(bbc_remove), |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 269 | .shutdown = sparcspkr_shutdown, |
| 270 | }; |
| 271 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 272 | static int __devinit grover_beep_probe(struct platform_device *op, const struct of_device_id *match) |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 273 | { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 274 | struct sparcspkr_state *state; |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 275 | struct grover_beep_info *info; |
| 276 | int err = -ENOMEM; |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 277 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 278 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
| 279 | if (!state) |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 280 | goto out_err; |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 281 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 282 | state->name = "Sparc Grover Speaker"; |
| 283 | state->event = grover_spkr_event; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 284 | spin_lock_init(&state->lock); |
| 285 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 286 | info = &state->u.grover; |
| 287 | info->freq_regs = of_ioremap(&op->resource[2], 0, 2, "grover beep freq"); |
| 288 | if (!info->freq_regs) |
| 289 | goto out_free; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 290 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 291 | info->enable_reg = of_ioremap(&op->resource[3], 0, 1, "grover beep enable"); |
| 292 | if (!info->enable_reg) |
| 293 | goto out_unmap_freq_regs; |
| 294 | |
| 295 | dev_set_drvdata(&op->dev, state); |
| 296 | |
| 297 | err = sparcspkr_probe(&op->dev); |
| 298 | if (err) |
| 299 | goto out_clear_drvdata; |
| 300 | |
| 301 | return 0; |
| 302 | |
| 303 | out_clear_drvdata: |
| 304 | dev_set_drvdata(&op->dev, NULL); |
| 305 | of_iounmap(&op->resource[3], info->enable_reg, 1); |
| 306 | |
| 307 | out_unmap_freq_regs: |
| 308 | of_iounmap(&op->resource[2], info->freq_regs, 2); |
| 309 | out_free: |
| 310 | kfree(state); |
| 311 | out_err: |
| 312 | return err; |
| 313 | } |
| 314 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 315 | static int __devexit grover_remove(struct platform_device *op) |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 316 | { |
| 317 | struct sparcspkr_state *state = dev_get_drvdata(&op->dev); |
| 318 | struct grover_beep_info *info = &state->u.grover; |
| 319 | struct input_dev *input_dev = state->input_dev; |
| 320 | |
| 321 | /* turn off the speaker */ |
| 322 | state->event(input_dev, EV_SND, SND_BELL, 0); |
| 323 | |
| 324 | input_unregister_device(input_dev); |
| 325 | |
| 326 | of_iounmap(&op->resource[3], info->enable_reg, 1); |
| 327 | of_iounmap(&op->resource[2], info->freq_regs, 2); |
| 328 | |
| 329 | dev_set_drvdata(&op->dev, NULL); |
| 330 | kfree(state); |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 331 | |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 332 | return 0; |
Dmitry Torokhov | f5b6407 | 2005-12-21 00:52:35 -0500 | [diff] [blame] | 333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
David S. Miller | fd09831 | 2008-08-31 01:23:17 -0700 | [diff] [blame] | 335 | static const struct of_device_id grover_beep_match[] = { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 336 | { |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 337 | .name = "beep", |
| 338 | .compatible = "SUNW,smbus-beep", |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 339 | }, |
| 340 | {}, |
| 341 | }; |
| 342 | |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 343 | static struct of_platform_driver grover_beep_driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 344 | .driver = { |
| 345 | .name = "groverbeep", |
| 346 | .owner = THIS_MODULE, |
| 347 | .of_match_table = grover_beep_match, |
| 348 | }, |
David S. Miller | 9c1a507 | 2008-04-26 21:02:21 -0700 | [diff] [blame] | 349 | .probe = grover_beep_probe, |
| 350 | .remove = __devexit_p(grover_remove), |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 351 | .shutdown = sparcspkr_shutdown, |
| 352 | }; |
| 353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | static int __init sparcspkr_init(void) |
| 355 | { |
Grant Likely | 1ab1d63 | 2010-06-24 15:14:37 -0600 | [diff] [blame] | 356 | int err = of_register_platform_driver(&bbc_beep_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 358 | if (!err) { |
Grant Likely | 1ab1d63 | 2010-06-24 15:14:37 -0600 | [diff] [blame] | 359 | err = of_register_platform_driver(&grover_beep_driver); |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 360 | if (err) |
Grant Likely | 1ab1d63 | 2010-06-24 15:14:37 -0600 | [diff] [blame] | 361 | of_unregister_platform_driver(&bbc_beep_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 364 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | static void __exit sparcspkr_exit(void) |
| 368 | { |
Grant Likely | 1ab1d63 | 2010-06-24 15:14:37 -0600 | [diff] [blame] | 369 | of_unregister_platform_driver(&bbc_beep_driver); |
| 370 | of_unregister_platform_driver(&grover_beep_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | module_init(sparcspkr_init); |
| 374 | module_exit(sparcspkr_exit); |