rack-meter.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * RackMac vu-meter driver
  3. *
  4. * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
  5. * <benh@kernel.crashing.org>
  6. *
  7. * Released under the term of the GNU GPL v2.
  8. *
  9. * Support the CPU-meter LEDs of the Xserve G5
  10. *
  11. * TODO: Implement PWM to do variable intensity and provide userland
  12. * interface for fun. Also, the CPU-meter could be made nicer by being
  13. * a bit less "immediate" but giving instead a more average load over
  14. * time. Patches welcome :-)
  15. *
  16. */
  17. #undef DEBUG
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <linux/slab.h>
  21. #include <linux/device.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/module.h>
  24. #include <linux/pci.h>
  25. #include <linux/dma-mapping.h>
  26. #include <linux/kernel_stat.h>
  27. #include <asm/io.h>
  28. #include <asm/prom.h>
  29. #include <asm/machdep.h>
  30. #include <asm/pmac_feature.h>
  31. #include <asm/dbdma.h>
  32. #include <asm/macio.h>
  33. #include <asm/keylargo.h>
  34. /* Number of samples in a sample buffer */
  35. #define SAMPLE_COUNT 256
  36. /* CPU meter sampling rate in ms */
  37. #define CPU_SAMPLING_RATE 250
  38. struct rackmeter_dma {
  39. struct dbdma_cmd cmd[4] ____cacheline_aligned;
  40. u32 mark ____cacheline_aligned;
  41. u32 buf1[SAMPLE_COUNT] ____cacheline_aligned;
  42. u32 buf2[SAMPLE_COUNT] ____cacheline_aligned;
  43. } ____cacheline_aligned;
  44. struct rackmeter_cpu {
  45. struct delayed_work sniffer;
  46. struct rackmeter *rm;
  47. cputime64_t prev_wall;
  48. cputime64_t prev_idle;
  49. int zero;
  50. } ____cacheline_aligned;
  51. struct rackmeter {
  52. struct macio_dev *mdev;
  53. unsigned int irq;
  54. struct device_node *i2s;
  55. u8 *ubuf;
  56. struct dbdma_regs __iomem *dma_regs;
  57. void __iomem *i2s_regs;
  58. dma_addr_t dma_buf_p;
  59. struct rackmeter_dma *dma_buf_v;
  60. int stale_irq;
  61. struct rackmeter_cpu cpu[2];
  62. int paused;
  63. struct mutex sem;
  64. };
  65. /* To be set as a tunable */
  66. static int rackmeter_ignore_nice;
  67. /* This GPIO is whacked by the OS X driver when initializing */
  68. #define RACKMETER_MAGIC_GPIO 0x78
  69. /* This is copied from cpufreq_ondemand, maybe we should put it in
  70. * a common header somewhere
  71. */
  72. static inline cputime64_t get_cpu_idle_time(unsigned int cpu)
  73. {
  74. u64 retval;
  75. retval = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE] +
  76. kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
  77. if (rackmeter_ignore_nice)
  78. retval += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
  79. return retval;
  80. }
  81. static void rackmeter_setup_i2s(struct rackmeter *rm)
  82. {
  83. struct macio_chip *macio = rm->mdev->bus->chip;
  84. /* First whack magic GPIO */
  85. pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, RACKMETER_MAGIC_GPIO, 5);
  86. /* Call feature code to enable the sound channel and the proper
  87. * clock sources
  88. */
  89. pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, rm->i2s, 0, 1);
  90. /* Power i2s and stop i2s clock. We whack MacIO FCRs directly for now.
  91. * This is a bit racy, thus we should add new platform functions to
  92. * handle that. snd-aoa needs that too
  93. */
  94. MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE);
  95. MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
  96. (void)MACIO_IN32(KEYLARGO_FCR1);
  97. udelay(10);
  98. /* Then setup i2s. For now, we use the same magic value that
  99. * the OS X driver seems to use. We might want to play around
  100. * with the clock divisors later
  101. */
  102. out_le32(rm->i2s_regs + 0x10, 0x01fa0000);
  103. (void)in_le32(rm->i2s_regs + 0x10);
  104. udelay(10);
  105. /* Fully restart i2s*/
  106. MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE |
  107. KL1_I2S0_CLK_ENABLE_BIT);
  108. (void)MACIO_IN32(KEYLARGO_FCR1);
  109. udelay(10);
  110. }
  111. static void rackmeter_set_default_pattern(struct rackmeter *rm)
  112. {
  113. int i;
  114. for (i = 0; i < 16; i++) {
  115. if (i < 8)
  116. rm->ubuf[i] = (i & 1) * 255;
  117. else
  118. rm->ubuf[i] = ((~i) & 1) * 255;
  119. }
  120. }
  121. static void rackmeter_do_pause(struct rackmeter *rm, int pause)
  122. {
  123. struct rackmeter_dma *rdma = rm->dma_buf_v;
  124. pr_debug("rackmeter: %s\n", pause ? "paused" : "started");
  125. rm->paused = pause;
  126. if (pause) {
  127. DBDMA_DO_STOP(rm->dma_regs);
  128. return;
  129. }
  130. memset(rdma->buf1, 0, SAMPLE_COUNT & sizeof(u32));
  131. memset(rdma->buf2, 0, SAMPLE_COUNT & sizeof(u32));
  132. rm->dma_buf_v->mark = 0;
  133. mb();
  134. out_le32(&rm->dma_regs->cmdptr_hi, 0);
  135. out_le32(&rm->dma_regs->cmdptr, rm->dma_buf_p);
  136. out_le32(&rm->dma_regs->control, (RUN << 16) | RUN);
  137. }
  138. static void rackmeter_setup_dbdma(struct rackmeter *rm)
  139. {
  140. struct rackmeter_dma *db = rm->dma_buf_v;
  141. struct dbdma_cmd *cmd = db->cmd;
  142. /* Make sure dbdma is reset */
  143. DBDMA_DO_RESET(rm->dma_regs);
  144. pr_debug("rackmeter: mark offset=0x%zx\n",
  145. offsetof(struct rackmeter_dma, mark));
  146. pr_debug("rackmeter: buf1 offset=0x%zx\n",
  147. offsetof(struct rackmeter_dma, buf1));
  148. pr_debug("rackmeter: buf2 offset=0x%zx\n",
  149. offsetof(struct rackmeter_dma, buf2));
  150. /* Prepare 4 dbdma commands for the 2 buffers */
  151. memset(cmd, 0, 4 * sizeof(struct dbdma_cmd));
  152. st_le16(&cmd->req_count, 4);
  153. st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM);
  154. st_le32(&cmd->phy_addr, rm->dma_buf_p +
  155. offsetof(struct rackmeter_dma, mark));
  156. st_le32(&cmd->cmd_dep, 0x02000000);
  157. cmd++;
  158. st_le16(&cmd->req_count, SAMPLE_COUNT * 4);
  159. st_le16(&cmd->command, OUTPUT_MORE);
  160. st_le32(&cmd->phy_addr, rm->dma_buf_p +
  161. offsetof(struct rackmeter_dma, buf1));
  162. cmd++;
  163. st_le16(&cmd->req_count, 4);
  164. st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM);
  165. st_le32(&cmd->phy_addr, rm->dma_buf_p +
  166. offsetof(struct rackmeter_dma, mark));
  167. st_le32(&cmd->cmd_dep, 0x01000000);
  168. cmd++;
  169. st_le16(&cmd->req_count, SAMPLE_COUNT * 4);
  170. st_le16(&cmd->command, OUTPUT_MORE | BR_ALWAYS);
  171. st_le32(&cmd->phy_addr, rm->dma_buf_p +
  172. offsetof(struct rackmeter_dma, buf2));
  173. st_le32(&cmd->cmd_dep, rm->dma_buf_p);
  174. rackmeter_do_pause(rm, 0);
  175. }
  176. static void rackmeter_do_timer(struct work_struct *work)
  177. {
  178. struct rackmeter_cpu *rcpu =
  179. container_of(work, struct rackmeter_cpu, sniffer.work);
  180. struct rackmeter *rm = rcpu->rm;
  181. unsigned int cpu = smp_processor_id();
  182. cputime64_t cur_jiffies, total_idle_ticks;
  183. unsigned int total_ticks, idle_ticks;
  184. int i, offset, load, cumm, pause;
  185. cur_jiffies = jiffies64_to_cputime64(get_jiffies_64());
  186. total_ticks = (unsigned int) (cur_jiffies - rcpu->prev_wall);
  187. rcpu->prev_wall = cur_jiffies;
  188. total_idle_ticks = get_cpu_idle_time(cpu);
  189. idle_ticks = (unsigned int) (total_idle_ticks - rcpu->prev_idle);
  190. rcpu->prev_idle = total_idle_ticks;
  191. /* We do a very dumb calculation to update the LEDs for now,
  192. * we'll do better once we have actual PWM implemented
  193. */
  194. load = (9 * (total_ticks - idle_ticks)) / total_ticks;
  195. offset = cpu << 3;
  196. cumm = 0;
  197. for (i = 0; i < 8; i++) {
  198. u8 ub = (load > i) ? 0xff : 0;
  199. rm->ubuf[i + offset] = ub;
  200. cumm |= ub;
  201. }
  202. rcpu->zero = (cumm == 0);
  203. /* Now check if LEDs are all 0, we can stop DMA */
  204. pause = (rm->cpu[0].zero && rm->cpu[1].zero);
  205. if (pause != rm->paused) {
  206. mutex_lock(&rm->sem);
  207. pause = (rm->cpu[0].zero && rm->cpu[1].zero);
  208. rackmeter_do_pause(rm, pause);
  209. mutex_unlock(&rm->sem);
  210. }
  211. schedule_delayed_work_on(cpu, &rcpu->sniffer,
  212. msecs_to_jiffies(CPU_SAMPLING_RATE));
  213. }
  214. static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm)
  215. {
  216. unsigned int cpu;
  217. /* This driver works only with 1 or 2 CPUs numbered 0 and 1,
  218. * but that's really all we have on Apple Xserve. It doesn't
  219. * play very nice with CPU hotplug neither but we don't do that
  220. * on those machines yet
  221. */
  222. rm->cpu[0].rm = rm;
  223. INIT_DELAYED_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer);
  224. rm->cpu[1].rm = rm;
  225. INIT_DELAYED_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer);
  226. for_each_online_cpu(cpu) {
  227. struct rackmeter_cpu *rcpu;
  228. if (cpu > 1)
  229. continue;
  230. rcpu = &rm->cpu[cpu];
  231. rcpu->prev_idle = get_cpu_idle_time(cpu);
  232. rcpu->prev_wall = jiffies64_to_cputime64(get_jiffies_64());
  233. schedule_delayed_work_on(cpu, &rm->cpu[cpu].sniffer,
  234. msecs_to_jiffies(CPU_SAMPLING_RATE));
  235. }
  236. }
  237. static void rackmeter_stop_cpu_sniffer(struct rackmeter *rm)
  238. {
  239. cancel_delayed_work_sync(&rm->cpu[0].sniffer);
  240. cancel_delayed_work_sync(&rm->cpu[1].sniffer);
  241. }
  242. static int __devinit rackmeter_setup(struct rackmeter *rm)
  243. {
  244. pr_debug("rackmeter: setting up i2s..\n");
  245. rackmeter_setup_i2s(rm);
  246. pr_debug("rackmeter: setting up default pattern..\n");
  247. rackmeter_set_default_pattern(rm);
  248. pr_debug("rackmeter: setting up dbdma..\n");
  249. rackmeter_setup_dbdma(rm);
  250. pr_debug("rackmeter: start CPU measurements..\n");
  251. rackmeter_init_cpu_sniffer(rm);
  252. printk(KERN_INFO "RackMeter initialized\n");
  253. return 0;
  254. }
  255. /* XXX FIXME: No PWM yet, this is 0/1 */
  256. static u32 rackmeter_calc_sample(struct rackmeter *rm, unsigned int index)
  257. {
  258. int led;
  259. u32 sample = 0;
  260. for (led = 0; led < 16; led++) {
  261. sample >>= 1;
  262. sample |= ((rm->ubuf[led] >= 0x80) << 15);
  263. }
  264. return (sample << 17) | (sample >> 15);
  265. }
  266. static irqreturn_t rackmeter_irq(int irq, void *arg)
  267. {
  268. struct rackmeter *rm = arg;
  269. struct rackmeter_dma *db = rm->dma_buf_v;
  270. unsigned int mark, i;
  271. u32 *buf;
  272. /* Flush PCI buffers with an MMIO read. Maybe we could actually
  273. * check the status one day ... in case things go wrong, though
  274. * this never happened to me
  275. */
  276. (void)in_le32(&rm->dma_regs->status);
  277. /* Make sure the CPU gets us in order */
  278. rmb();
  279. /* Read mark */
  280. mark = db->mark;
  281. if (mark != 1 && mark != 2) {
  282. printk(KERN_WARNING "rackmeter: Incorrect DMA mark 0x%08x\n",
  283. mark);
  284. /* We allow for 3 errors like that (stale DBDMA irqs) */
  285. if (++rm->stale_irq > 3) {
  286. printk(KERN_ERR "rackmeter: Too many errors,"
  287. " stopping DMA\n");
  288. DBDMA_DO_RESET(rm->dma_regs);
  289. }
  290. return IRQ_HANDLED;
  291. }
  292. /* Next buffer we need to fill is mark value */
  293. buf = mark == 1 ? db->buf1 : db->buf2;
  294. /* Fill it now. This routine converts the 8 bits depth sample array
  295. * into the PWM bitmap for each LED.
  296. */
  297. for (i = 0; i < SAMPLE_COUNT; i++)
  298. buf[i] = rackmeter_calc_sample(rm, i);
  299. return IRQ_HANDLED;
  300. }
  301. static int __devinit rackmeter_probe(struct macio_dev* mdev,
  302. const struct of_device_id *match)
  303. {
  304. struct device_node *i2s = NULL, *np = NULL;
  305. struct rackmeter *rm = NULL;
  306. struct resource ri2s, rdma;
  307. int rc = -ENODEV;
  308. pr_debug("rackmeter_probe()\n");
  309. /* Get i2s-a node */
  310. while ((i2s = of_get_next_child(mdev->ofdev.dev.of_node, i2s)) != NULL)
  311. if (strcmp(i2s->name, "i2s-a") == 0)
  312. break;
  313. if (i2s == NULL) {
  314. pr_debug(" i2s-a child not found\n");
  315. goto bail;
  316. }
  317. /* Get lightshow or virtual sound */
  318. while ((np = of_get_next_child(i2s, np)) != NULL) {
  319. if (strcmp(np->name, "lightshow") == 0)
  320. break;
  321. if ((strcmp(np->name, "sound") == 0) &&
  322. of_get_property(np, "virtual", NULL) != NULL)
  323. break;
  324. }
  325. if (np == NULL) {
  326. pr_debug(" lightshow or sound+virtual child not found\n");
  327. goto bail;
  328. }
  329. /* Create and initialize our instance data */
  330. rm = kzalloc(sizeof(struct rackmeter), GFP_KERNEL);
  331. if (rm == NULL) {
  332. printk(KERN_ERR "rackmeter: failed to allocate memory !\n");
  333. rc = -ENOMEM;
  334. goto bail_release;
  335. }
  336. rm->mdev = mdev;
  337. rm->i2s = i2s;
  338. mutex_init(&rm->sem);
  339. dev_set_drvdata(&mdev->ofdev.dev, rm);
  340. /* Check resources availability. We need at least resource 0 and 1 */
  341. #if 0 /* Use that when i2s-a is finally an mdev per-se */
  342. if (macio_resource_count(mdev) < 2 || macio_irq_count(mdev) < 2) {
  343. printk(KERN_ERR
  344. "rackmeter: found match but lacks resources: %s"
  345. " (%d resources, %d interrupts)\n",
  346. mdev->ofdev.node->full_name);
  347. rc = -ENXIO;
  348. goto bail_free;
  349. }
  350. if (macio_request_resources(mdev, "rackmeter")) {
  351. printk(KERN_ERR
  352. "rackmeter: failed to request resources: %s\n",
  353. mdev->ofdev.node->full_name);
  354. rc = -EBUSY;
  355. goto bail_free;
  356. }
  357. rm->irq = macio_irq(mdev, 1);
  358. #else
  359. rm->irq = irq_of_parse_and_map(i2s, 1);
  360. if (rm->irq == NO_IRQ ||
  361. of_address_to_resource(i2s, 0, &ri2s) ||
  362. of_address_to_resource(i2s, 1, &rdma)) {
  363. printk(KERN_ERR
  364. "rackmeter: found match but lacks resources: %s",
  365. mdev->ofdev.dev.of_node->full_name);
  366. rc = -ENXIO;
  367. goto bail_free;
  368. }
  369. #endif
  370. pr_debug(" i2s @0x%08x\n", (unsigned int)ri2s.start);
  371. pr_debug(" dma @0x%08x\n", (unsigned int)rdma.start);
  372. pr_debug(" irq %d\n", rm->irq);
  373. rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL);
  374. if (rm->ubuf == NULL) {
  375. printk(KERN_ERR
  376. "rackmeter: failed to allocate samples page !\n");
  377. rc = -ENOMEM;
  378. goto bail_release;
  379. }
  380. rm->dma_buf_v = dma_alloc_coherent(&macio_get_pci_dev(mdev)->dev,
  381. sizeof(struct rackmeter_dma),
  382. &rm->dma_buf_p, GFP_KERNEL);
  383. if (rm->dma_buf_v == NULL) {
  384. printk(KERN_ERR
  385. "rackmeter: failed to allocate dma buffer !\n");
  386. rc = -ENOMEM;
  387. goto bail_free_samples;
  388. }
  389. #if 0
  390. rm->i2s_regs = ioremap(macio_resource_start(mdev, 0), 0x1000);
  391. #else
  392. rm->i2s_regs = ioremap(ri2s.start, 0x1000);
  393. #endif
  394. if (rm->i2s_regs == NULL) {
  395. printk(KERN_ERR
  396. "rackmeter: failed to map i2s registers !\n");
  397. rc = -ENXIO;
  398. goto bail_free_dma;
  399. }
  400. #if 0
  401. rm->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x100);
  402. #else
  403. rm->dma_regs = ioremap(rdma.start, 0x100);
  404. #endif
  405. if (rm->dma_regs == NULL) {
  406. printk(KERN_ERR
  407. "rackmeter: failed to map dma registers !\n");
  408. rc = -ENXIO;
  409. goto bail_unmap_i2s;
  410. }
  411. rc = rackmeter_setup(rm);
  412. if (rc) {
  413. printk(KERN_ERR
  414. "rackmeter: failed to initialize !\n");
  415. rc = -ENXIO;
  416. goto bail_unmap_dma;
  417. }
  418. rc = request_irq(rm->irq, rackmeter_irq, 0, "rackmeter", rm);
  419. if (rc != 0) {
  420. printk(KERN_ERR
  421. "rackmeter: failed to request interrupt !\n");
  422. goto bail_stop_dma;
  423. }
  424. of_node_put(np);
  425. return 0;
  426. bail_stop_dma:
  427. DBDMA_DO_RESET(rm->dma_regs);
  428. bail_unmap_dma:
  429. iounmap(rm->dma_regs);
  430. bail_unmap_i2s:
  431. iounmap(rm->i2s_regs);
  432. bail_free_dma:
  433. dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
  434. sizeof(struct rackmeter_dma),
  435. rm->dma_buf_v, rm->dma_buf_p);
  436. bail_free_samples:
  437. free_page((unsigned long)rm->ubuf);
  438. bail_release:
  439. #if 0
  440. macio_release_resources(mdev);
  441. #endif
  442. bail_free:
  443. kfree(rm);
  444. bail:
  445. of_node_put(i2s);
  446. of_node_put(np);
  447. dev_set_drvdata(&mdev->ofdev.dev, NULL);
  448. return rc;
  449. }
  450. static int __devexit rackmeter_remove(struct macio_dev* mdev)
  451. {
  452. struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
  453. /* Stop CPU sniffer timer & work queues */
  454. rackmeter_stop_cpu_sniffer(rm);
  455. /* Clear reference to private data */
  456. dev_set_drvdata(&mdev->ofdev.dev, NULL);
  457. /* Stop/reset dbdma */
  458. DBDMA_DO_RESET(rm->dma_regs);
  459. /* Release the IRQ */
  460. free_irq(rm->irq, rm);
  461. /* Unmap registers */
  462. iounmap(rm->dma_regs);
  463. iounmap(rm->i2s_regs);
  464. /* Free DMA */
  465. dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
  466. sizeof(struct rackmeter_dma),
  467. rm->dma_buf_v, rm->dma_buf_p);
  468. /* Free samples */
  469. free_page((unsigned long)rm->ubuf);
  470. #if 0
  471. /* Release resources */
  472. macio_release_resources(mdev);
  473. #endif
  474. /* Get rid of me */
  475. kfree(rm);
  476. return 0;
  477. }
  478. static int rackmeter_shutdown(struct macio_dev* mdev)
  479. {
  480. struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
  481. if (rm == NULL)
  482. return -ENODEV;
  483. /* Stop CPU sniffer timer & work queues */
  484. rackmeter_stop_cpu_sniffer(rm);
  485. /* Stop/reset dbdma */
  486. DBDMA_DO_RESET(rm->dma_regs);
  487. return 0;
  488. }
  489. static struct of_device_id rackmeter_match[] = {
  490. { .name = "i2s" },
  491. { }
  492. };
  493. static struct macio_driver rackmeter_driver = {
  494. .driver = {
  495. .name = "rackmeter",
  496. .owner = THIS_MODULE,
  497. .of_match_table = rackmeter_match,
  498. },
  499. .probe = rackmeter_probe,
  500. .remove = __devexit_p(rackmeter_remove),
  501. .shutdown = rackmeter_shutdown,
  502. };
  503. static int __init rackmeter_init(void)
  504. {
  505. pr_debug("rackmeter_init()\n");
  506. return macio_register_driver(&rackmeter_driver);
  507. }
  508. static void __exit rackmeter_exit(void)
  509. {
  510. pr_debug("rackmeter_exit()\n");
  511. macio_unregister_driver(&rackmeter_driver);
  512. }
  513. module_init(rackmeter_init);
  514. module_exit(rackmeter_exit);
  515. MODULE_LICENSE("GPL");
  516. MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
  517. MODULE_DESCRIPTION("RackMeter: Support vu-meter on XServe front panel");