rack-meter.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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. cputime64_t retval;
  75. retval = cputime64_add(kstat_cpu(cpu).cpustat.idle,
  76. kstat_cpu(cpu).cpustat.iowait);
  77. if (rackmeter_ignore_nice)
  78. retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.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)cputime64_sub(cur_jiffies,
  187. rcpu->prev_wall);
  188. rcpu->prev_wall = cur_jiffies;
  189. total_idle_ticks = get_cpu_idle_time(cpu);
  190. idle_ticks = (unsigned int) cputime64_sub(total_idle_ticks,
  191. rcpu->prev_idle);
  192. rcpu->prev_idle = total_idle_ticks;
  193. /* We do a very dumb calculation to update the LEDs for now,
  194. * we'll do better once we have actual PWM implemented
  195. */
  196. load = (9 * (total_ticks - idle_ticks)) / total_ticks;
  197. offset = cpu << 3;
  198. cumm = 0;
  199. for (i = 0; i < 8; i++) {
  200. u8 ub = (load > i) ? 0xff : 0;
  201. rm->ubuf[i + offset] = ub;
  202. cumm |= ub;
  203. }
  204. rcpu->zero = (cumm == 0);
  205. /* Now check if LEDs are all 0, we can stop DMA */
  206. pause = (rm->cpu[0].zero && rm->cpu[1].zero);
  207. if (pause != rm->paused) {
  208. mutex_lock(&rm->sem);
  209. pause = (rm->cpu[0].zero && rm->cpu[1].zero);
  210. rackmeter_do_pause(rm, pause);
  211. mutex_unlock(&rm->sem);
  212. }
  213. schedule_delayed_work_on(cpu, &rcpu->sniffer,
  214. msecs_to_jiffies(CPU_SAMPLING_RATE));
  215. }
  216. static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm)
  217. {
  218. unsigned int cpu;
  219. /* This driver works only with 1 or 2 CPUs numbered 0 and 1,
  220. * but that's really all we have on Apple Xserve. It doesn't
  221. * play very nice with CPU hotplug neither but we don't do that
  222. * on those machines yet
  223. */
  224. rm->cpu[0].rm = rm;
  225. INIT_DELAYED_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer);
  226. rm->cpu[1].rm = rm;
  227. INIT_DELAYED_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer);
  228. for_each_online_cpu(cpu) {
  229. struct rackmeter_cpu *rcpu;
  230. if (cpu > 1)
  231. continue;
  232. rcpu = &rm->cpu[cpu];
  233. rcpu->prev_idle = get_cpu_idle_time(cpu);
  234. rcpu->prev_wall = jiffies64_to_cputime64(get_jiffies_64());
  235. schedule_delayed_work_on(cpu, &rm->cpu[cpu].sniffer,
  236. msecs_to_jiffies(CPU_SAMPLING_RATE));
  237. }
  238. }
  239. static void rackmeter_stop_cpu_sniffer(struct rackmeter *rm)
  240. {
  241. cancel_delayed_work_sync(&rm->cpu[0].sniffer);
  242. cancel_delayed_work_sync(&rm->cpu[1].sniffer);
  243. }
  244. static int __devinit rackmeter_setup(struct rackmeter *rm)
  245. {
  246. pr_debug("rackmeter: setting up i2s..\n");
  247. rackmeter_setup_i2s(rm);
  248. pr_debug("rackmeter: setting up default pattern..\n");
  249. rackmeter_set_default_pattern(rm);
  250. pr_debug("rackmeter: setting up dbdma..\n");
  251. rackmeter_setup_dbdma(rm);
  252. pr_debug("rackmeter: start CPU measurements..\n");
  253. rackmeter_init_cpu_sniffer(rm);
  254. printk(KERN_INFO "RackMeter initialized\n");
  255. return 0;
  256. }
  257. /* XXX FIXME: No PWM yet, this is 0/1 */
  258. static u32 rackmeter_calc_sample(struct rackmeter *rm, unsigned int index)
  259. {
  260. int led;
  261. u32 sample = 0;
  262. for (led = 0; led < 16; led++) {
  263. sample >>= 1;
  264. sample |= ((rm->ubuf[led] >= 0x80) << 15);
  265. }
  266. return (sample << 17) | (sample >> 15);
  267. }
  268. static irqreturn_t rackmeter_irq(int irq, void *arg)
  269. {
  270. struct rackmeter *rm = arg;
  271. struct rackmeter_dma *db = rm->dma_buf_v;
  272. unsigned int mark, i;
  273. u32 *buf;
  274. /* Flush PCI buffers with an MMIO read. Maybe we could actually
  275. * check the status one day ... in case things go wrong, though
  276. * this never happened to me
  277. */
  278. (void)in_le32(&rm->dma_regs->status);
  279. /* Make sure the CPU gets us in order */
  280. rmb();
  281. /* Read mark */
  282. mark = db->mark;
  283. if (mark != 1 && mark != 2) {
  284. printk(KERN_WARNING "rackmeter: Incorrect DMA mark 0x%08x\n",
  285. mark);
  286. /* We allow for 3 errors like that (stale DBDMA irqs) */
  287. if (++rm->stale_irq > 3) {
  288. printk(KERN_ERR "rackmeter: Too many errors,"
  289. " stopping DMA\n");
  290. DBDMA_DO_RESET(rm->dma_regs);
  291. }
  292. return IRQ_HANDLED;
  293. }
  294. /* Next buffer we need to fill is mark value */
  295. buf = mark == 1 ? db->buf1 : db->buf2;
  296. /* Fill it now. This routine converts the 8 bits depth sample array
  297. * into the PWM bitmap for each LED.
  298. */
  299. for (i = 0; i < SAMPLE_COUNT; i++)
  300. buf[i] = rackmeter_calc_sample(rm, i);
  301. return IRQ_HANDLED;
  302. }
  303. static int __devinit rackmeter_probe(struct macio_dev* mdev,
  304. const struct of_device_id *match)
  305. {
  306. struct device_node *i2s = NULL, *np = NULL;
  307. struct rackmeter *rm = NULL;
  308. struct resource ri2s, rdma;
  309. int rc = -ENODEV;
  310. pr_debug("rackmeter_probe()\n");
  311. /* Get i2s-a node */
  312. while ((i2s = of_get_next_child(mdev->ofdev.dev.of_node, i2s)) != NULL)
  313. if (strcmp(i2s->name, "i2s-a") == 0)
  314. break;
  315. if (i2s == NULL) {
  316. pr_debug(" i2s-a child not found\n");
  317. goto bail;
  318. }
  319. /* Get lightshow or virtual sound */
  320. while ((np = of_get_next_child(i2s, np)) != NULL) {
  321. if (strcmp(np->name, "lightshow") == 0)
  322. break;
  323. if ((strcmp(np->name, "sound") == 0) &&
  324. of_get_property(np, "virtual", NULL) != NULL)
  325. break;
  326. }
  327. if (np == NULL) {
  328. pr_debug(" lightshow or sound+virtual child not found\n");
  329. goto bail;
  330. }
  331. /* Create and initialize our instance data */
  332. rm = kzalloc(sizeof(struct rackmeter), GFP_KERNEL);
  333. if (rm == NULL) {
  334. printk(KERN_ERR "rackmeter: failed to allocate memory !\n");
  335. rc = -ENOMEM;
  336. goto bail_release;
  337. }
  338. rm->mdev = mdev;
  339. rm->i2s = i2s;
  340. mutex_init(&rm->sem);
  341. dev_set_drvdata(&mdev->ofdev.dev, rm);
  342. /* Check resources availability. We need at least resource 0 and 1 */
  343. #if 0 /* Use that when i2s-a is finally an mdev per-se */
  344. if (macio_resource_count(mdev) < 2 || macio_irq_count(mdev) < 2) {
  345. printk(KERN_ERR
  346. "rackmeter: found match but lacks resources: %s"
  347. " (%d resources, %d interrupts)\n",
  348. mdev->ofdev.node->full_name);
  349. rc = -ENXIO;
  350. goto bail_free;
  351. }
  352. if (macio_request_resources(mdev, "rackmeter")) {
  353. printk(KERN_ERR
  354. "rackmeter: failed to request resources: %s\n",
  355. mdev->ofdev.node->full_name);
  356. rc = -EBUSY;
  357. goto bail_free;
  358. }
  359. rm->irq = macio_irq(mdev, 1);
  360. #else
  361. rm->irq = irq_of_parse_and_map(i2s, 1);
  362. if (rm->irq == NO_IRQ ||
  363. of_address_to_resource(i2s, 0, &ri2s) ||
  364. of_address_to_resource(i2s, 1, &rdma)) {
  365. printk(KERN_ERR
  366. "rackmeter: found match but lacks resources: %s",
  367. mdev->ofdev.dev.of_node->full_name);
  368. rc = -ENXIO;
  369. goto bail_free;
  370. }
  371. #endif
  372. pr_debug(" i2s @0x%08x\n", (unsigned int)ri2s.start);
  373. pr_debug(" dma @0x%08x\n", (unsigned int)rdma.start);
  374. pr_debug(" irq %d\n", rm->irq);
  375. rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL);
  376. if (rm->ubuf == NULL) {
  377. printk(KERN_ERR
  378. "rackmeter: failed to allocate samples page !\n");
  379. rc = -ENOMEM;
  380. goto bail_release;
  381. }
  382. rm->dma_buf_v = dma_alloc_coherent(&macio_get_pci_dev(mdev)->dev,
  383. sizeof(struct rackmeter_dma),
  384. &rm->dma_buf_p, GFP_KERNEL);
  385. if (rm->dma_buf_v == NULL) {
  386. printk(KERN_ERR
  387. "rackmeter: failed to allocate dma buffer !\n");
  388. rc = -ENOMEM;
  389. goto bail_free_samples;
  390. }
  391. #if 0
  392. rm->i2s_regs = ioremap(macio_resource_start(mdev, 0), 0x1000);
  393. #else
  394. rm->i2s_regs = ioremap(ri2s.start, 0x1000);
  395. #endif
  396. if (rm->i2s_regs == NULL) {
  397. printk(KERN_ERR
  398. "rackmeter: failed to map i2s registers !\n");
  399. rc = -ENXIO;
  400. goto bail_free_dma;
  401. }
  402. #if 0
  403. rm->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x100);
  404. #else
  405. rm->dma_regs = ioremap(rdma.start, 0x100);
  406. #endif
  407. if (rm->dma_regs == NULL) {
  408. printk(KERN_ERR
  409. "rackmeter: failed to map dma registers !\n");
  410. rc = -ENXIO;
  411. goto bail_unmap_i2s;
  412. }
  413. rc = rackmeter_setup(rm);
  414. if (rc) {
  415. printk(KERN_ERR
  416. "rackmeter: failed to initialize !\n");
  417. rc = -ENXIO;
  418. goto bail_unmap_dma;
  419. }
  420. rc = request_irq(rm->irq, rackmeter_irq, 0, "rackmeter", rm);
  421. if (rc != 0) {
  422. printk(KERN_ERR
  423. "rackmeter: failed to request interrupt !\n");
  424. goto bail_stop_dma;
  425. }
  426. of_node_put(np);
  427. return 0;
  428. bail_stop_dma:
  429. DBDMA_DO_RESET(rm->dma_regs);
  430. bail_unmap_dma:
  431. iounmap(rm->dma_regs);
  432. bail_unmap_i2s:
  433. iounmap(rm->i2s_regs);
  434. bail_free_dma:
  435. dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
  436. sizeof(struct rackmeter_dma),
  437. rm->dma_buf_v, rm->dma_buf_p);
  438. bail_free_samples:
  439. free_page((unsigned long)rm->ubuf);
  440. bail_release:
  441. #if 0
  442. macio_release_resources(mdev);
  443. #endif
  444. bail_free:
  445. kfree(rm);
  446. bail:
  447. of_node_put(i2s);
  448. of_node_put(np);
  449. dev_set_drvdata(&mdev->ofdev.dev, NULL);
  450. return rc;
  451. }
  452. static int __devexit rackmeter_remove(struct macio_dev* mdev)
  453. {
  454. struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
  455. /* Stop CPU sniffer timer & work queues */
  456. rackmeter_stop_cpu_sniffer(rm);
  457. /* Clear reference to private data */
  458. dev_set_drvdata(&mdev->ofdev.dev, NULL);
  459. /* Stop/reset dbdma */
  460. DBDMA_DO_RESET(rm->dma_regs);
  461. /* Release the IRQ */
  462. free_irq(rm->irq, rm);
  463. /* Unmap registers */
  464. iounmap(rm->dma_regs);
  465. iounmap(rm->i2s_regs);
  466. /* Free DMA */
  467. dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
  468. sizeof(struct rackmeter_dma),
  469. rm->dma_buf_v, rm->dma_buf_p);
  470. /* Free samples */
  471. free_page((unsigned long)rm->ubuf);
  472. #if 0
  473. /* Release resources */
  474. macio_release_resources(mdev);
  475. #endif
  476. /* Get rid of me */
  477. kfree(rm);
  478. return 0;
  479. }
  480. static int rackmeter_shutdown(struct macio_dev* mdev)
  481. {
  482. struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
  483. if (rm == NULL)
  484. return -ENODEV;
  485. /* Stop CPU sniffer timer & work queues */
  486. rackmeter_stop_cpu_sniffer(rm);
  487. /* Stop/reset dbdma */
  488. DBDMA_DO_RESET(rm->dma_regs);
  489. return 0;
  490. }
  491. static struct of_device_id rackmeter_match[] = {
  492. { .name = "i2s" },
  493. { }
  494. };
  495. static struct macio_driver rackmeter_driver = {
  496. .driver = {
  497. .name = "rackmeter",
  498. .owner = THIS_MODULE,
  499. .of_match_table = rackmeter_match,
  500. },
  501. .probe = rackmeter_probe,
  502. .remove = __devexit_p(rackmeter_remove),
  503. .shutdown = rackmeter_shutdown,
  504. };
  505. static int __init rackmeter_init(void)
  506. {
  507. pr_debug("rackmeter_init()\n");
  508. return macio_register_driver(&rackmeter_driver);
  509. }
  510. static void __exit rackmeter_exit(void)
  511. {
  512. pr_debug("rackmeter_exit()\n");
  513. macio_unregister_driver(&rackmeter_driver);
  514. }
  515. module_init(rackmeter_init);
  516. module_exit(rackmeter_exit);
  517. MODULE_LICENSE("GPL");
  518. MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
  519. MODULE_DESCRIPTION("RackMeter: Support vu-meter on XServe front panel");