arch/powerpc/platforms/85xx/sgy_cts1000.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/85xx/sgy_cts1000.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/85xx/sgy_cts1000.c- Extension
.c- Size
- 3591 bytes
- Lines
- 155
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/platform_device.hlinux/device.hlinux/gpio/consumer.hlinux/module.hlinux/of_irq.hlinux/workqueue.hlinux/reboot.hlinux/interrupt.hasm/machdep.h
Detected Declarations
function gpio_halt_wfnfunction gpio_halt_cbfunction gpio_halt_irqfunction __gpio_halt_probefunction gpio_halt_probefunction gpio_halt_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Servergy CTS-1000 Setup
*
* Maintained by Ben Collins <ben.c@servergy.com>
*
* Copyright 2012 by Servergy, Inc.
*/
#define pr_fmt(fmt) "gpio-halt: " fmt
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of_irq.h>
#include <linux/workqueue.h>
#include <linux/reboot.h>
#include <linux/interrupt.h>
#include <asm/machdep.h>
static struct gpio_desc *halt_gpio;
static int halt_irq;
static const struct of_device_id child_match[] = {
{
.compatible = "sgy,gpio-halt",
},
{},
};
static void gpio_halt_wfn(struct work_struct *work)
{
/* Likely wont return */
orderly_poweroff(true);
}
static DECLARE_WORK(gpio_halt_wq, gpio_halt_wfn);
static void __noreturn gpio_halt_cb(void)
{
pr_info("triggering GPIO.\n");
/* Probably wont return */
gpiod_set_value(halt_gpio, 1);
panic("Halt failed\n");
}
/* This IRQ means someone pressed the power button and it is waiting for us
* to handle the shutdown/poweroff. */
static irqreturn_t gpio_halt_irq(int irq, void *__data)
{
struct platform_device *pdev = __data;
dev_info(&pdev->dev, "scheduling shutdown due to power button IRQ\n");
schedule_work(&gpio_halt_wq);
return IRQ_HANDLED;
};
static int __gpio_halt_probe(struct platform_device *pdev,
struct device_node *halt_node)
{
int err;
halt_gpio = fwnode_gpiod_get_index(of_fwnode_handle(halt_node),
NULL, 0, GPIOD_OUT_LOW, "gpio-halt");
err = PTR_ERR_OR_ZERO(halt_gpio);
if (err) {
dev_err(&pdev->dev, "failed to request halt GPIO: %d\n", err);
return err;
}
/* Now get the IRQ which tells us when the power button is hit */
halt_irq = irq_of_parse_and_map(halt_node, 0);
err = request_irq(halt_irq, gpio_halt_irq,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"gpio-halt", pdev);
if (err) {
dev_err(&pdev->dev, "failed to request IRQ %d: %d\n",
halt_irq, err);
gpiod_put(halt_gpio);
halt_gpio = NULL;
return err;
}
/* Register our halt function */
ppc_md.halt = gpio_halt_cb;
Annotation
- Immediate include surface: `linux/err.h`, `linux/platform_device.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/of_irq.h`, `linux/workqueue.h`, `linux/reboot.h`.
- Detected declarations: `function gpio_halt_wfn`, `function gpio_halt_cb`, `function gpio_halt_irq`, `function __gpio_halt_probe`, `function gpio_halt_probe`, `function gpio_halt_remove`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.