1*16216333SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2e86169ffSYoichi Yuasa /* 3e86169ffSYoichi Yuasa * Registration of Cobalt LED platform device. 4e86169ffSYoichi Yuasa * 5ada8e951SYoichi Yuasa * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> 6e86169ffSYoichi Yuasa */ 7e86169ffSYoichi Yuasa #include <linux/errno.h> 8e86169ffSYoichi Yuasa #include <linux/init.h> 9e86169ffSYoichi Yuasa #include <linux/ioport.h> 10e86169ffSYoichi Yuasa #include <linux/platform_device.h> 11e86169ffSYoichi Yuasa 129a203755SYoichi Yuasa #include <cobalt.h> 139a203755SYoichi Yuasa 14e86169ffSYoichi Yuasa static struct resource cobalt_led_resource __initdata = { 15e86169ffSYoichi Yuasa .start = 0x1c000000, 16e86169ffSYoichi Yuasa .end = 0x1c000000, 17e86169ffSYoichi Yuasa .flags = IORESOURCE_MEM, 18e86169ffSYoichi Yuasa }; 19e86169ffSYoichi Yuasa 20e86169ffSYoichi Yuasa static __init int cobalt_led_add(void) 21e86169ffSYoichi Yuasa { 22e86169ffSYoichi Yuasa struct platform_device *pdev; 23e86169ffSYoichi Yuasa int retval; 24e86169ffSYoichi Yuasa 259a203755SYoichi Yuasa if (cobalt_board_id == COBALT_BRD_ID_QUBE1 || 269a203755SYoichi Yuasa cobalt_board_id == COBALT_BRD_ID_QUBE2) 279a203755SYoichi Yuasa pdev = platform_device_alloc("cobalt-qube-leds", -1); 289a203755SYoichi Yuasa else 29e86169ffSYoichi Yuasa pdev = platform_device_alloc("cobalt-raq-leds", -1); 30e86169ffSYoichi Yuasa 31e86169ffSYoichi Yuasa if (!pdev) 32e86169ffSYoichi Yuasa return -ENOMEM; 33e86169ffSYoichi Yuasa 34e86169ffSYoichi Yuasa retval = platform_device_add_resources(pdev, &cobalt_led_resource, 1); 35e86169ffSYoichi Yuasa if (retval) 36e86169ffSYoichi Yuasa goto err_free_device; 37e86169ffSYoichi Yuasa 38e86169ffSYoichi Yuasa retval = platform_device_add(pdev); 39e86169ffSYoichi Yuasa if (retval) 40e86169ffSYoichi Yuasa goto err_free_device; 41e86169ffSYoichi Yuasa 42e86169ffSYoichi Yuasa return 0; 43e86169ffSYoichi Yuasa 44e86169ffSYoichi Yuasa err_free_device: 45e86169ffSYoichi Yuasa platform_device_put(pdev); 46e86169ffSYoichi Yuasa 47e86169ffSYoichi Yuasa return retval; 48e86169ffSYoichi Yuasa } 49e86169ffSYoichi Yuasa device_initcall(cobalt_led_add); 50