示例#1
0
文件: editmsg.c 项目: wfp5p/elm
int edit_message(const char *filename, SEND_HEADER *shdr,
		 const char *sel_editor)
{
    /* Return 0 if successful, -1 on error. */

    char buffer[SLEN];
    int rc, return_value = 0, err;

    /* pick default editor on NULL */
    if (sel_editor == NULL)
	sel_editor = (IS_BUILTIN(editor) ? alternative_editor : editor);

    /* handle request for the builtin editor */
    if (IS_BUILTIN(sel_editor))
	return builtin_editor(filename, shdr);

    /* we will be running an external editor */
    PutLine(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmInvokeEditor,
	    "Invoking editor..."));

    if (strstr(sel_editor, "%s") != NULL)
	sprintf(buffer, sel_editor, filename);
    else
	sprintf(buffer, "%s %s", sel_editor, filename);

    chown(filename, userid, groupid);

    if ((rc = system_call(buffer, SY_COOKED|SY_ENAB_SIGHUP|SY_DUMPSTATE)) < 0) {
	err = errno;
	dprint(1, (debugfile,
	    "System call failed with status %d (edit_message)\n", rc));
	dprint(1, (debugfile, "** %s **\n", strerror(err)));
	ClearLine(LINES-1);
	show_error(catgets(elm_msg_cat, ElmSet, ElmCantInvokeEditor,
	    "Can't invoke editor '%s' for composition."), sel_editor);
	if (sleepmsg > 0)
	    sleep(sleepmsg);
	return_value = -1;
    }

    /* Flush input buffer.  This is especially important under X,
    * where accidental keystrokes in the elm window could make
    * things messy.
    */
    if (edit_flush)
	FlushInput();

    return return_value;
}
示例#2
0
void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
{
	struct bcma_bus *bus = cc->core->bus;

	if (cc->early_setup_done)
		return;

	spin_lock_init(&cc->gpio_lock);

	if (cc->core->id.rev >= 11)
		cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
	cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
	if (cc->core->id.rev >= 35)
		cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);

	if (cc->capabilities & BCMA_CC_CAP_PMU)
		bcma_pmu_early_init(cc);

	if (IS_BUILTIN(CONFIG_BCM47XX) && bus->hosttype == BCMA_HOSTTYPE_SOC)
		bcma_chipco_serial_init(cc);

	if (bus->hosttype == BCMA_HOSTTYPE_SOC)
		bcma_core_chipcommon_flash_detect(cc);

	cc->early_setup_done = true;
}
示例#3
0
static int do_bootz_linux_fdt(int fd, struct image_data *data)
{
	struct fdt_header __header, *header;
	void *oftree;
	int ret;

	u32 end;

	if (data->oftree)
		return -ENXIO;

	header = &__header;
	ret = read(fd, header, sizeof(*header));
	if (ret < sizeof(*header))
		return ret;

	if (file_detect_type(header, sizeof(*header)) != filetype_oftree)
		return -ENXIO;

	end = be32_to_cpu(header->totalsize);

	oftree = malloc(end + 0x8000);
	if (!oftree) {
		perror("zImage: oftree malloc");
		return -ENOMEM;
	}

	memcpy(oftree, header, sizeof(*header));

	end -= sizeof(*header);

	ret = read_full(fd, oftree + sizeof(*header), end);
	if (ret < 0)
		goto err_free;
	if (ret < end) {
		printf("premature end of image\n");
		ret = -EIO;
		goto err_free;
	}

	if (IS_BUILTIN(CONFIG_OFTREE)) {
		data->of_root_node = of_unflatten_dtb(NULL, oftree);
		if (!data->of_root_node) {
			pr_err("unable to unflatten devicetree\n");
			ret = -EINVAL;
			goto err_free;
		}
	} else {
		data->oftree = oftree;
	}

	pr_info("zImage: concatenated oftree detected\n");

	return 0;

err_free:
	free(oftree);

	return ret;
}
示例#4
0
文件: mach-imx6q.c 项目: KDr2/linux
static void __init imx6q_sabrelite_init(void)
{
	if (IS_BUILTIN(CONFIG_PHYLIB))
		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
				ksz9021rn_phy_fixup);
	imx6q_sabrelite_cko1_setup();
}
示例#5
0
static int armlinux_register_image_handler(void)
{
	register_image_handler(&barebox_handler);
	register_image_handler(&uimage_handler);
	register_image_handler(&rawimage_handler);
	register_image_handler(&zimage_handler);
	if (IS_BUILTIN(CONFIG_BOOTM_AIMAGE)) {
		register_image_handler(&aimage_handler);
		binfmt_register(&binfmt_aimage_hook);
	}
	if (IS_BUILTIN(CONFIG_FITIMAGE))
	        register_image_handler(&arm_fit_handler);
	binfmt_register(&binfmt_arm_zimage_hook);
	binfmt_register(&binfmt_barebox_hook);

	return 0;
}
示例#6
0
static void __init imx7d_enet_phy_init(void)
{
	if (IS_BUILTIN(CONFIG_PHYLIB)) {
		phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
					   ar8031_phy_fixup);
		phy_register_fixup_for_uid(PHY_ID_BCM54220, 0xffffffff,
					   bcm54220_phy_fixup);
	}
}
示例#7
0
int bcma_gpio_init(struct bcma_drv_cc *cc)
{
	struct bcma_bus *bus = cc->core->bus;
	struct gpio_chip *chip = &cc->gpio;
	int err;

	chip->label		= "bcma_gpio";
	chip->owner		= THIS_MODULE;
	chip->request		= bcma_gpio_request;
	chip->free		= bcma_gpio_free;
	chip->get		= bcma_gpio_get_value;
	chip->set		= bcma_gpio_set_value;
	chip->direction_input	= bcma_gpio_direction_input;
	chip->direction_output	= bcma_gpio_direction_output;
	chip->owner		= THIS_MODULE;
	chip->parent		= bus->dev;
#if IS_BUILTIN(CONFIG_OF)
	chip->of_node		= cc->core->dev.of_node;
#endif
	switch (bus->chipinfo.id) {
	case BCMA_CHIP_ID_BCM4707:
	case BCMA_CHIP_ID_BCM5357:
	case BCMA_CHIP_ID_BCM53572:
	case BCMA_CHIP_ID_BCM53573:
	case BCMA_CHIP_ID_BCM47094:
		chip->ngpio	= 32;
		break;
	default:
		chip->ngpio	= 16;
	}

	/*
	 * Register SoC GPIO devices with absolute GPIO pin base.
	 * On MIPS, we don't have Device Tree and we can't use relative (per chip)
	 * GPIO numbers.
	 * On some ARM devices, user space may want to access some system GPIO
	 * pins directly, which is easier to do with a predictable GPIO base.
	 */
	if (IS_BUILTIN(CONFIG_BCM47XX) ||
	    cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
		chip->base		= bus->num * BCMA_GPIO_MAX_PINS;
	else
		chip->base		= -1;

	err = gpiochip_add_data(chip, cc);
	if (err)
		return err;

	err = bcma_gpio_irq_init(cc);
	if (err) {
		gpiochip_remove(chip);
		return err;
	}

	return 0;
}
示例#8
0
/*
 * close a uImage previously opened with uimage_open
 */
void uimage_close(struct uimage_handle *handle)
{
	struct stat s;

	close(handle->fd);
	free(handle->name);
	free(handle);

	if (IS_BUILTIN(CONFIG_FS_TFTP) && !stat(uimage_tmp, &s))
		unlink(uimage_tmp);
}
示例#9
0
static void __init imx6q_enet_phy_init(void)
{
	if (IS_BUILTIN(CONFIG_PHYLIB)) {
		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
				ksz9021rn_phy_fixup);
		phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK,
				ksz9031rn_phy_fixup);
		phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
				ar8031_phy_fixup);
		phy_register_fixup_for_uid(PHY_ID_AR8035, 0xffffffef,
				ar8035_phy_fixup);
	}
}
示例#10
0
文件: common.c 项目: Aayush-N/linux
void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context)
{
	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
	off_t offset = (off_t)context;

	if (!IS_BUILTIN(CONFIG_NVMEM)) {
		pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n");
		return;
	}

	/* Read MAC addr from EEPROM */
	if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
		pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
}
示例#11
0
文件: mach-imx6q.c 项目: KDr2/linux
/* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
static int ksz9021rn_phy_fixup(struct phy_device *phydev)
{
	if (IS_BUILTIN(CONFIG_PHYLIB)) {
		/* min rx data delay */
		phy_write(phydev, 0x0b, 0x8105);
		phy_write(phydev, 0x0c, 0x0000);

		/* max rx/tx clock delay, min rx/tx control delay */
		phy_write(phydev, 0x0b, 0x8104);
		phy_write(phydev, 0x0c, 0xf0f0);
		phy_write(phydev, 0x0b, 0x104);
	}

	return 0;
}
示例#12
0
// Executes a <simple> redirection. If background == true, the command is
// executed in the background. Returns the <simple>'s status, or 0 if background
// is true and we don't wait for it to die.
int processSimple(CMD* cmd, bool background)
{
    if(IS_BUILTIN(cmd->argv[0]))
    {
        int status = execBuiltin(cmd);
        updateStatusVar(status);
        return status;
    }
    
    int pid;
    if((pid = fork()) < 0)
    {
        // error in forking
        perror(EXEC_NAME);
        return errno;
    }
    else if(pid == 0)
    {
        // child
        if(redirect(cmd) < 0)
        {
            exit(errno);
        }
        execvp(cmd->argv[0], cmd->argv);
        perror(EXEC_NAME);
        exit(EXIT_FAILURE);
    }
    else
    {
        // parent        
        if(background)
        {
            return 0;
        }
        else
        {
            int status;
            signal(SIGINT, SIG_IGN);
            waitpid(pid, &status, 0);
            signal(SIGINT, SIG_DFL);
            
            int exitStatus = GET_STATUS(status);
            updateStatusVar(exitStatus);
            return exitStatus;
        }
    }
}
示例#13
0
/* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
static int ksz9021rn_phy_fixup(struct phy_device *phydev)
{
	if (IS_BUILTIN(CONFIG_PHYLIB)) {
		/* min rx data delay */
		phy_write(phydev, MICREL_KSZ9021_EXTREG_CTRL,
			0x8000 | MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW);
		phy_write(phydev, MICREL_KSZ9021_EXTREG_DATA_WRITE, 0x0000);

		/* max rx/tx clock delay, min rx/tx control delay */
		phy_write(phydev, MICREL_KSZ9021_EXTREG_CTRL,
			0x8000 | MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW);
		phy_write(phydev, MICREL_KSZ9021_EXTREG_DATA_WRITE, 0xf0f0);
		phy_write(phydev, MICREL_KSZ9021_EXTREG_CTRL,
			MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW);
	}

	return 0;
}
示例#14
0
void __init orion_ge00_switch_init(struct dsa_chip_data *d)
{
	unsigned int i;

	if (!IS_BUILTIN(CONFIG_PHYLIB))
		return;

	for (i = 0; i < ARRAY_SIZE(d->port_names); i++) {
		if (!strcmp(d->port_names[i], "cpu")) {
			d->netdev[i] = &orion_ge00.dev;
			break;
		}
	}

	orion_ge00_switch_board_info.mdio_addr = d->sw_addr;
	orion_ge00_switch_board_info.platform_data = d;

	mdiobus_register_board_info(&orion_ge00_switch_board_info, 1);
}
示例#15
0
static int osk_tps_setup(struct i2c_client *client, void *context)
{
	if (!IS_BUILTIN(CONFIG_TPS65010))
		return -ENOSYS;

	/* Set GPIO 1 HIGH to disable VBUS power supply;
	 * OHCI driver powers it up/down as needed.
	 */
	gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
	gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);

	/* Set GPIO 2 high so LED D3 is off by default */
	tps65010_set_gpio_out_value(GPIO2, HIGH);

	/* Set GPIO 3 low to take ethernet out of reset */
	gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
	gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);

	/* GPIO4 is VDD_DSP */
	gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
	gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
	/* REVISIT if DSP support isn't configured, power it off ... */

	/* Let LED1 (D9) blink; leds-gpio may override it */
	tps65010_set_led(LED1, BLINK);

	/* Set LED2 off by default */
	tps65010_set_led(LED2, OFF);

	/* Enable LOW_PWR handshake */
	tps65010_set_low_pwr(ON);

	/* Switch VLDO2 to 3.0V for AIC23 */
	tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
			| TPS_LDO1_ENABLE);

	/* register these three LEDs */
	osk5912_tps_leds.dev.parent = &client->dev;
	platform_device_register(&osk5912_tps_leds);

	return 0;
}
示例#16
0
/*
 * open a uimage. This will check the header contents and
 * return a handle to the uImage
 */
struct uimage_handle *uimage_open(const char *filename)
{
	int fd;
	uint32_t checksum;
	struct uimage_handle *handle;
	struct image_header *header;
	int i;
	int ret;
	struct stat s;

again:
	fd = open(filename, O_RDONLY);
	if (fd < 0) {
		printf("could not open: %s\n", errno_str());
		return NULL;
	}

	/*
	 * Hack around tftp fs. We need lseek for uImage support, but
	 * this cannot be implemented in tftp fs, so we detect this
	 * by doing a test lseek and copy the file to ram if it fails
	 */
	if (IS_BUILTIN(CONFIG_FS_TFTP) && lseek(fd, 0, SEEK_SET)) {
		close(fd);
		ret = copy_file(filename, uimage_tmp, 0);
		if (ret)
			return NULL;
		filename = uimage_tmp;
		goto again;
	}

	handle = xzalloc(sizeof(struct uimage_handle));
	header = &handle->header;

	if (read(fd, header, sizeof(*header)) < 0) {
		printf("could not read: %s\n", errno_str());
		goto err_out;
	}

	if (uimage_to_cpu(header->ih_magic) != IH_MAGIC) {
		printf("Bad Magic Number\n");
		goto err_out;
	}

	checksum = uimage_to_cpu(header->ih_hcrc);
	header->ih_hcrc = 0;

	if (crc32(0, header, sizeof(*header)) != checksum) {
		printf("Bad Header Checksum\n");
		goto err_out;
	}

	/* convert header to cpu native endianess */
	header->ih_magic = uimage_to_cpu(header->ih_magic);
	header->ih_hcrc = uimage_to_cpu(header->ih_hcrc);
	header->ih_time = uimage_to_cpu(header->ih_time);
	header->ih_size = uimage_to_cpu(header->ih_size);
	header->ih_load = uimage_to_cpu(header->ih_load);
	header->ih_ep = uimage_to_cpu(header->ih_ep);
	header->ih_dcrc = uimage_to_cpu(header->ih_dcrc);

	if (header->ih_name[0]) {
		handle->name = xzalloc(IH_NMLEN + 1);
		strncpy(handle->name, header->ih_name, IH_NMLEN);
	} else {
		handle->name = xstrdup(filename);
	}

	if (uimage_is_multi_image(handle)) {
		size_t offset;

		for (i = 0; i < MAX_MULTI_IMAGE_COUNT; i++) {
			u32 size;

			ret = read(fd, &size, sizeof(size));
			if (ret < 0)
				goto err_out;

			if (!size)
				break;

			handle->ihd[i].len = uimage_to_cpu(size);
		}

		handle->nb_data_entries = i;

		/* offset of the first image in a multifile image */
		offset = 0;

		for (i = 0; i < handle->nb_data_entries; i++) {
			handle->ihd[i].offset = offset;
			offset += (handle->ihd[i].len + 3) & ~3;
		}

		handle->data_offset = sizeof(struct image_header) +
			sizeof(u32) * (handle->nb_data_entries + 1);
	} else {
		handle->ihd[0].offset = 0;
		handle->ihd[0].len = header->ih_size;
		handle->nb_data_entries = 1;
		handle->data_offset = sizeof(struct image_header);
	}

	/*
	 * fd is now at the first data word
	 */
	handle->fd = fd;

	return handle;
err_out:
	close(fd);
	free(handle);
	if (IS_BUILTIN(CONFIG_FS_TFTP) && !stat(uimage_tmp, &s))
		unlink(uimage_tmp);
	return NULL;
}
示例#17
0
// Executes a pipeline and returns the exit status of the pipe. The arg
// pipeRoot is the PIPE or PIPE_ERR command at the root of the pipeline.
// This function draws upon code from Professor Stan Eisenstat at Yale
// University
int execPipe(CMD* pipeRoot)
{
    // count the number of stages in the pipeline
    int numStages = 1;
    for(CMD* cmd = pipeRoot; ISPIPE(cmd->type); cmd = cmd->right, numStages++);
    
    // create table to hold pid and exit status of all stages in the pipe
    struct {
        int pid, status;
    } processTable[numStages];
    
    int fd[2];             // holds file descriptors for the pipe
    int pid, status;       //   the pid and status of a single stage
    int fdIn = STDIN_FD;   //   the read end of the last pipe, or the original
                           //   stdin
    
    CMD* cmd = pipeRoot;
    for(int i = 0; ISPIPE(cmd->type); cmd = cmd->right, i++)
    {
        if(pipe(fd) < 0 || (pid = fork()) < 0)
        {
            perror(EXEC_NAME);
            return errno;
        }
        else if(pid == 0)
        {
            // child
            close(fd[0]);
            
            // redirect stdin to the last pipe read (if there was a last pipe)
            if(fdIn != STDIN_FD)
            {
                dup2(fdIn, STDIN_FD);
                close(fdIn);
            }
            
            bool shouldCloseFD1 = false;
            // redirect stdout to the new pipe write (if it's not stdout)
            if(fd[1] != STDOUT_FD)
            {
                dup2(fd[1], STDOUT_FD);
                shouldCloseFD1 = true;
            }
            
            // if this is a PIPE_ERR, redirect stderr to the new pipe write
            // (if it's not stderr)
            if(cmd->type == PIPE_ERR && fd[1] != STDERR_FD)
            {
                dup2(fd[1], STDERR_FD);
                shouldCloseFD1 = true;
            }
            
            if(shouldCloseFD1) close(fd[1]);
            
            exit(processStage(cmd->left));
        }
        else
        {
            // parent
            processTable[i].pid = pid;
            
            // close the read end of the last pipe if it's not the orig stdin
            if(i > 0)
            {
                close(fdIn);
            }
            
            fdIn = fd[0]; // remember the read end of the new pipe
            close(fd[1]);
        }
    }
    // cmd is now the right child of last PIPE or PIPE_ERR, the last stage of
    // the pipeline
    
    // if the last stage is a built-in command, it should affect the parent
    // shell, so execute it here instead of forking off a process
    if(cmd->type == SIMPLE && IS_BUILTIN(cmd->argv[0]))
    {
        processTable[numStages - 1].pid = -1; // unused pid
        processTable[numStages - 1].status = processSimple(cmd, false);
        close(fdIn);
    }
    else if((pid = fork()) < 0)
    {
        perror(EXEC_NAME);
        return errno;
    }
    else if(pid == 0)
    {
        // child
        if(fdIn != STDIN_FD)
        {
            dup2(fdIn, STDIN_FD);
            close(fdIn);
        }
        exit(processStage(cmd));
    }
    else
    {
        // parent
        processTable[numStages - 1].pid = pid;
        close(fdIn);
    }
    
    // wait for children to die
    signal(SIGINT, SIG_IGN);
    for(int i = 0; i < numStages; )
    {
        pid = wait(&status);
        int j;
        for(j = 0; j < numStages && processTable[j].pid != pid; j++);
        
        // only add to the processTable if the child's pid is in the table;
        // that is, ignore zombies
        if(j < numStages)
        {
            processTable[j].status = status;
            i++;
        }
    }
    signal(SIGINT, SIG_DFL);
    
    for(int i = 0; i < numStages; i++)
    {
        if(GET_STATUS(processTable[i].status) != 0)
        {
            return GET_STATUS(processTable[i].status);
        }
    }
    return 0;
}
示例#18
0
文件: bootm.c 项目: Jokymon/barebox
static int do_bootz_linux_fdt(int fd, struct image_data *data)
{
	struct fdt_header __header, *header;
	struct resource *r = data->os_res;
	struct resource *of_res = data->os_res;
	void *oftree;
	int ret;

	u32 end;

	header = &__header;
	ret = read(fd, header, sizeof(*header));
	if (ret < sizeof(*header))
		return ret;

	if (file_detect_type(header) != filetype_oftree)
		return -ENXIO;

	end = be32_to_cpu(header->totalsize);

	if (IS_BUILTIN(CONFIG_OFTREE)) {
		oftree = malloc(end + 0x8000);
		if (!oftree) {
			perror("zImage: oftree malloc");
			return -ENOMEM;
		}
	} else {

		of_res = request_sdram_region("oftree", r->start + resource_size(r), end);
		if (!of_res) {
			perror("zImage: oftree request_sdram_region");
			return -ENOMEM;
		}

		oftree = (void*)of_res->start;
	}

	memcpy(oftree, header, sizeof(*header));

	end -= sizeof(*header);

	ret = read_full(fd, oftree + sizeof(*header), end);
	if (ret < 0)
		return ret;
	if (ret < end) {
		printf("premature end of image\n");
		return -EIO;
	}

	if (IS_BUILTIN(CONFIG_OFTREE)) {
		fdt_open_into(oftree, oftree, end + 0x8000);

		ret = of_fix_tree(oftree);
		if (ret)
			return ret;

		data->oftree = oftree;
	}

	pr_info("zImage: concatenated oftree detected\n");

	return 0;
}
static void __init dns323_init(void)
{
	/* Setup basic Orion functions. Need to be called early. */
	orion5x_init();

	/* Identify revision */
	system_rev = dns323_identify_rev();
	pr_info("DNS-323: Identified HW revision %c1\n", 'A' + system_rev);

	/* Just to be tricky, the 5182 has a completely different
	 * set of MPP modes to the 5181.
	 */
	switch(system_rev) {
	case DNS323_REV_A1:
		orion5x_mpp_conf(dns323a_mpp_modes);
		writel(0, MPP_DEV_CTRL);		/* DEV_D[31:16] */
		break;
	case DNS323_REV_B1:
		orion5x_mpp_conf(dns323b_mpp_modes);
		break;
	case DNS323_REV_C1:
		orion5x_mpp_conf(dns323c_mpp_modes);
		break;
	}

	/* setup flash mapping
	 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
	 */
	mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
				    ORION_MBUS_DEVBUS_BOOT_ATTR,
				    DNS323_NOR_BOOT_BASE,
				    DNS323_NOR_BOOT_SIZE);
	platform_device_register(&dns323_nor_flash);

	/* Sort out LEDs, Buttons and i2c devices */
	switch(system_rev) {
	case DNS323_REV_A1:
		/* The 5181 power LED is active low and requires
		 * DNS323_GPIO_LED_POWER1 to also be low.
		 */
		 dns323ab_leds[0].active_low = 1;
		 gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
		 gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
		/* Fall through */
	case DNS323_REV_B1:
		i2c_register_board_info(0, dns323ab_i2c_devices,
				ARRAY_SIZE(dns323ab_i2c_devices));
		break;
	case DNS323_REV_C1:
		/* Hookup LEDs & Buttons */
		dns323_gpio_leds.dev.platform_data = &dns323c_led_data;
		dns323_button_device.dev.platform_data = &dns323c_button_data;

		/* Hookup i2c devices and fan driver */
		i2c_register_board_info(0, dns323c_i2c_devices,
				ARRAY_SIZE(dns323c_i2c_devices));
		platform_device_register_simple("dns323c-fan", 0, NULL, 0);

		/* Register fixup for the PHY LEDs */
		if (!IS_BUILTIN(CONFIG_PHYLIB))
			break;
		phy_register_fixup_for_uid(MARVELL_PHY_ID_88E1118,
					   MARVELL_PHY_ID_MASK,
					   dns323c_phy_fixup);
	}

	platform_device_register(&dns323_gpio_leds);
	platform_device_register(&dns323_button_device);

	/*
	 * Configure peripherals.
	 */
	if (dns323_read_mac_addr() < 0)
		printk("DNS-323: Failed to read MAC address\n");
	orion5x_ehci0_init();
	orion5x_eth_init(&dns323_eth_data);
	orion5x_i2c_init();
	orion5x_uart0_init();

	/* Remaining GPIOs */
	switch(system_rev) {
	case DNS323_REV_A1:
		/* Poweroff GPIO */
		if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
		    gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
			pr_err("DNS-323: failed to setup power-off GPIO\n");
		pm_power_off = dns323a_power_off;
		break;
	case DNS323_REV_B1:
		/* 5182 built-in SATA init */
		orion5x_sata_init(&dns323_sata_data);

		/* The DNS323 rev B1 has flag to indicate the system is up.
		 * Without this flag set, power LED will flash and cannot be
		 * controlled via leds-gpio.
		 */
		if (gpio_request(DNS323_GPIO_SYSTEM_UP, "SYS_READY") == 0)
			gpio_direction_output(DNS323_GPIO_SYSTEM_UP, 1);

		/* Poweroff GPIO */
		if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
		    gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
			pr_err("DNS-323: failed to setup power-off GPIO\n");
		pm_power_off = dns323b_power_off;
		break;
	case DNS323_REV_C1:
		/* 5182 built-in SATA init */
		orion5x_sata_init(&dns323_sata_data);

		/* Poweroff GPIO */
		if (gpio_request(DNS323C_GPIO_POWER_OFF, "POWEROFF") != 0 ||
		    gpio_direction_output(DNS323C_GPIO_POWER_OFF, 0) != 0)
			pr_err("DNS-323: failed to setup power-off GPIO\n");
		pm_power_off = dns323c_power_off;

		/* Now, -this- should theorically be done by the sata_mv driver
		 * once I figure out what's going on there. Maybe the behaviour
		 * of the LEDs should be somewhat passed via the platform_data.
		 * for now, just whack the register and make the LEDs happy
		 *
		 * Note: AFAIK, rev B1 needs the same treatement but I'll let
		 * somebody else test it.
		 */
		writel(0x5, ORION5X_SATA_VIRT_BASE + 0x2c);
		break;
	}
}
示例#20
0
static void __init imx6sx_enet_phy_init(void)
{
	if (IS_BUILTIN(CONFIG_PHYLIB))
		phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
					   ar8031_phy_fixup);
}