^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* central.c: Central FHC driver for Sunfire/Starfire/Wildfire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 1997, 1999, 2008 David S. Miller (davem@davemloft.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/fhc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/upa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct clock_board {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) void __iomem *clock_freq_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void __iomem *clock_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void __iomem *clock_ver_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int num_slots;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct resource leds_resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct platform_device leds_pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct fhc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void __iomem *pregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) bool central;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) bool jtag_master;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int board_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct resource leds_resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct platform_device leds_pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static int clock_board_calc_nslots(struct clock_board *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) u8 reg = upa_readb(p->clock_regs + CLOCK_STAT1) & 0xc0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) switch (reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) case 0x40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) case 0xc0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) case 0x80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) reg = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) if (p->clock_ver_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) reg = upa_readb(p->clock_ver_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if (reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (reg & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static int clock_board_probe(struct platform_device *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (!p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) printk(KERN_ERR "clock_board: Cannot allocate struct clock_board\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) p->clock_freq_regs = of_ioremap(&op->resource[0], 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) resource_size(&op->resource[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) "clock_board_freq");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!p->clock_freq_regs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) printk(KERN_ERR "clock_board: Cannot map clock_freq_regs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) p->clock_regs = of_ioremap(&op->resource[1], 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) resource_size(&op->resource[1]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) "clock_board_regs");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (!p->clock_regs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) printk(KERN_ERR "clock_board: Cannot map clock_regs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) goto out_unmap_clock_freq_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (op->resource[2].flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) p->clock_ver_reg = of_ioremap(&op->resource[2], 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) resource_size(&op->resource[2]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) "clock_ver_reg");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (!p->clock_ver_reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) printk(KERN_ERR "clock_board: Cannot map clock_ver_reg\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) goto out_unmap_clock_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) p->num_slots = clock_board_calc_nslots(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) p->leds_resource.start = (unsigned long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) (p->clock_regs + CLOCK_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) p->leds_resource.end = p->leds_resource.start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) p->leds_resource.name = "leds";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) p->leds_pdev.name = "sunfire-clockboard-leds";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) p->leds_pdev.id = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) p->leds_pdev.resource = &p->leds_resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) p->leds_pdev.num_resources = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) p->leds_pdev.dev.parent = &op->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) err = platform_device_register(&p->leds_pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) printk(KERN_ERR "clock_board: Could not register LEDS "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) "platform device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) goto out_unmap_clock_ver_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) printk(KERN_INFO "clock_board: Detected %d slot Enterprise system.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) p->num_slots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) out_unmap_clock_ver_reg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (p->clock_ver_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) of_iounmap(&op->resource[2], p->clock_ver_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) resource_size(&op->resource[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) out_unmap_clock_regs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) of_iounmap(&op->resource[1], p->clock_regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) resource_size(&op->resource[1]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) out_unmap_clock_freq_regs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) of_iounmap(&op->resource[0], p->clock_freq_regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) resource_size(&op->resource[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) kfree(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static const struct of_device_id clock_board_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) .name = "clock-board",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static struct platform_driver clock_board_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) .probe = clock_board_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .name = "clock_board",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) .of_match_table = clock_board_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static int fhc_probe(struct platform_device *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (!p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) printk(KERN_ERR "fhc: Cannot allocate struct fhc\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (of_node_name_eq(op->dev.of_node->parent, "central"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) p->central = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) p->pregs = of_ioremap(&op->resource[0], 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) resource_size(&op->resource[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) "fhc_pregs");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (!p->pregs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) printk(KERN_ERR "fhc: Cannot map pregs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (p->central) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) reg = upa_readl(p->pregs + FHC_PREGS_BSR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) p->board_num = ((reg >> 16) & 1) | ((reg >> 12) & 0x0e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) p->board_num = of_getintprop_default(op->dev.of_node, "board#", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (p->board_num == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) printk(KERN_ERR "fhc: No board# property\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) goto out_unmap_pregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (upa_readl(p->pregs + FHC_PREGS_JCTRL) & FHC_JTAG_CTRL_MENAB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) p->jtag_master = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (!p->central) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) p->leds_resource.start = (unsigned long)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) (p->pregs + FHC_PREGS_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) p->leds_resource.end = p->leds_resource.start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) p->leds_resource.name = "leds";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) p->leds_pdev.name = "sunfire-fhc-leds";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) p->leds_pdev.id = p->board_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) p->leds_pdev.resource = &p->leds_resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) p->leds_pdev.num_resources = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) p->leds_pdev.dev.parent = &op->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) err = platform_device_register(&p->leds_pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) printk(KERN_ERR "fhc: Could not register LEDS "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) "platform device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) goto out_unmap_pregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) reg = upa_readl(p->pregs + FHC_PREGS_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (!p->central)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) reg |= FHC_CONTROL_IXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) reg &= ~(FHC_CONTROL_AOFF |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) FHC_CONTROL_BOFF |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) FHC_CONTROL_SLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) upa_writel(reg, p->pregs + FHC_PREGS_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) upa_readl(p->pregs + FHC_PREGS_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) reg = upa_readl(p->pregs + FHC_PREGS_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) printk(KERN_INFO "fhc: Board #%d, Version[%x] PartID[%x] Manuf[%x] %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) p->board_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) (reg & FHC_ID_VERS) >> 28,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) (reg & FHC_ID_PARTID) >> 12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) (reg & FHC_ID_MANUF) >> 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) (p->jtag_master ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) "(JTAG Master)" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) (p->central ? "(Central)" : "")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) out_unmap_pregs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) of_iounmap(&op->resource[0], p->pregs, resource_size(&op->resource[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) kfree(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static const struct of_device_id fhc_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .name = "fhc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static struct platform_driver fhc_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .probe = fhc_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .name = "fhc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .of_match_table = fhc_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static int __init sunfire_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) (void) platform_driver_register(&fhc_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) (void) platform_driver_register(&clock_board_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) fs_initcall(sunfire_init);