arch/sparc/kernel/central.c

Source file repositories/reference/linux-study-clean/arch/sparc/kernel/central.c

File Facts

System
Linux kernel
Corpus path
arch/sparc/kernel/central.c
Extension
.c
Size
6088 bytes
Lines
272
Domain
Architecture Layer
Bucket
arch/sparc
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct clock_board {
	void __iomem		*clock_freq_regs;
	void __iomem		*clock_regs;
	void __iomem		*clock_ver_reg;
	int			num_slots;
	struct resource		leds_resource;
	struct platform_device	leds_pdev;
};

struct fhc {
	void __iomem		*pregs;
	bool			central;
	bool			jtag_master;
	int			board_num;
	struct resource		leds_resource;
	struct platform_device	leds_pdev;
};

static int clock_board_calc_nslots(struct clock_board *p)
{
	u8 reg = upa_readb(p->clock_regs + CLOCK_STAT1) & 0xc0;

	switch (reg) {
	case 0x40:
		return 16;

	case 0xc0:
		return 8;

	case 0x80:
		reg = 0;
		if (p->clock_ver_reg)
			reg = upa_readb(p->clock_ver_reg);
		if (reg) {
			if (reg & 0x80)
				return 4;
			else
				return 5;
		}
		fallthrough;
	default:
		return 4;
	}
}

static int clock_board_probe(struct platform_device *op)
{
	struct clock_board *p = kzalloc_obj(*p);
	int err = -ENOMEM;

	if (!p) {
		printk(KERN_ERR "clock_board: Cannot allocate struct clock_board\n");
		goto out;
	}

	p->clock_freq_regs = of_ioremap(&op->resource[0], 0,
					resource_size(&op->resource[0]),
					"clock_board_freq");
	if (!p->clock_freq_regs) {
		printk(KERN_ERR "clock_board: Cannot map clock_freq_regs\n");
		goto out_free;
	}

	p->clock_regs = of_ioremap(&op->resource[1], 0,
				   resource_size(&op->resource[1]),
				   "clock_board_regs");
	if (!p->clock_regs) {
		printk(KERN_ERR "clock_board: Cannot map clock_regs\n");
		goto out_unmap_clock_freq_regs;
	}

	if (op->resource[2].flags) {
		p->clock_ver_reg = of_ioremap(&op->resource[2], 0,
					      resource_size(&op->resource[2]),
					      "clock_ver_reg");
		if (!p->clock_ver_reg) {
			printk(KERN_ERR "clock_board: Cannot map clock_ver_reg\n");
			goto out_unmap_clock_regs;
		}
	}

	p->num_slots = clock_board_calc_nslots(p);

	p->leds_resource.start = (unsigned long)
		(p->clock_regs + CLOCK_CTRL);
	p->leds_resource.end = p->leds_resource.start;
	p->leds_resource.name = "leds";

	p->leds_pdev.name = "sunfire-clockboard-leds";
	p->leds_pdev.id = -1;

Annotation

Implementation Notes