arch/xtensa/platforms/xtfpga/setup.c

Source file repositories/reference/linux-study-clean/arch/xtensa/platforms/xtfpga/setup.c

File Facts

System
Linux kernel
Corpus path
arch/xtensa/platforms/xtfpga/setup.c
Extension
.c
Size
6944 bytes
Lines
302
Domain
Architecture Layer
Bucket
arch/xtensa
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

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *
 * arch/xtensa/platform/xtavnet/setup.c
 *
 * ...
 *
 * Authors:	Chris Zankel <chris@zankel.net>
 *		Joe Taylor <joe@tensilica.com>
 *
 * Copyright 2001 - 2006 Tensilica Inc.
 */
#include <linux/stddef.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/errno.h>
#include <linux/reboot.h>
#include <linux/kdev_t.h>
#include <linux/types.h>
#include <linux/major.h>
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/slab.h>

#include <asm/timex.h>
#include <asm/processor.h>
#include <asm/platform.h>
#include <asm/bootparam.h>
#include <platform/lcd.h>
#include <platform/hardware.h>

static int xtfpga_power_off(struct sys_off_data *unused)
{
	lcd_disp_at_pos("POWEROFF", 0);
	local_irq_disable();
	while (1)
		cpu_relax();
	return NOTIFY_DONE;
}

static int xtfpga_restart(struct sys_off_data *unused)
{
	/* Try software reset first. */
	WRITE_ONCE(*(u32 *)XTFPGA_SWRST_VADDR, 0xdead);

	/* If software reset did not work, flush and reset the mmu,
	 * simulate a processor reset, and jump to the reset vector.
	 */
	cpu_reset();

	return NOTIFY_DONE;
}

#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT

void __init platform_calibrate_ccount(void)
{
	ccount_freq = *(long *)XTFPGA_CLKFRQ_VADDR;
}

#endif

static void __init xtfpga_register_handlers(void)
{
	register_sys_off_handler(SYS_OFF_MODE_RESTART,
				 SYS_OFF_PRIO_PLATFORM,
				 xtfpga_restart, NULL);
	register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
				 SYS_OFF_PRIO_DEFAULT,
				 xtfpga_power_off, NULL);
}

#ifdef CONFIG_USE_OF

static void __init xtfpga_clk_setup(struct device_node *np)
{
	void __iomem *base = of_iomap(np, 0);
	struct clk *clk;
	u32 freq;

	if (!base) {
		pr_err("%pOFn: invalid address\n", np);
		return;
	}

	freq = __raw_readl(base);

Annotation

Implementation Notes