Ejemplo n.º 1
0
static int aximx5_lcd_set_power (struct lcd_device *ld, int state)
{
	struct mediaq11xx_base *mq_base = class_get_devdata (&ld->class_dev);
	int lcdfp_state = mq_base->get_power (mq_base, MEDIAQ_11XX_FP_DEVICE_ID) ? 1 : 0;
	int fpctl_state = mq_base->get_power (mq_base, MEDIAQ_11XX_FB_DEVICE_ID) ? 1 : 0;

	int new_lcdfp_state = (state < 1) ? 1 : 0;
	int new_fpctl_state = (state < 4) ? 1 : 0;

	debug_func ("state:%d\n", state);

	if (new_lcdfp_state != lcdfp_state)
		mq_base->set_power (mq_base, MEDIAQ_11XX_FP_DEVICE_ID, new_lcdfp_state);
	if (new_fpctl_state != fpctl_state)
		mq_base->set_power (mq_base, MEDIAQ_11XX_FB_DEVICE_ID, new_fpctl_state);

	if (new_lcdfp_state)
		/* MediaQ GPIO 1 seems connected to flat-panel power */
		mq_base->set_GPIO (mq_base, GPIO_NR_AXIMX5_MQ1132_FP_ENABLE, MQ_GPIO_OUT1);
	else
		/* Output '0' to MQ1132 GPIO 1 */
		mq_base->set_GPIO (mq_base, GPIO_NR_AXIMX5_MQ1132_FP_ENABLE, MQ_GPIO_OUT0);

	return 0;
}
Ejemplo n.º 2
0
void radeonfb_bl_exit(struct radeonfb_info *rinfo)
{
#ifdef CONFIG_PMAC_BACKLIGHT
	mutex_lock(&pmac_backlight_mutex);
#endif

	mutex_lock(&rinfo->info->bl_mutex);
	if (rinfo->info->bl_dev) {
		struct radeon_bl_privdata *pdata;

#ifdef CONFIG_PMAC_BACKLIGHT
		if (pmac_backlight == rinfo->info->bl_dev)
			pmac_backlight = NULL;
#endif

		pdata = class_get_devdata(&rinfo->info->bl_dev->class_dev);
		backlight_device_unregister(rinfo->info->bl_dev);
		kfree(pdata);
		rinfo->info->bl_dev = NULL;

		printk("radeonfb: Backlight unloaded\n");
	}
	mutex_unlock(&rinfo->info->bl_mutex);

#ifdef CONFIG_PMAC_BACKLIGHT
	mutex_unlock(&pmac_backlight_mutex);
#endif
}
Ejemplo n.º 3
0
static int
aximx5_lcd_set_contrast (struct lcd_device *ld, int contrast)
{
	struct mediaq11xx_base *mq_base = class_get_devdata (&ld->class_dev);
	u32 x;

	debug_func ("contrast:%d\n", contrast);

	/* Well... this is kind of tricky but here's how it works:
	 * On 24-bit TFT panels the R,G,B channels are output via
	 * the FD0..FD23 MQ1132' outputs. There are separate enable
	 * bits for these pins in FP07R, which we will use.
	 * Basically we just mask out (setting them to '1')
	 * the lowest 1..8 bits of every color component thus
	 * effectively reducing the number of bits for them.
	 */
	if (contrast > 7)
		contrast = 7;
	contrast = 7 ^ contrast;

	x = (1 << contrast) - 1;

	mq_base->regs->FP.pin_output_data |= 0x00ffffff;
	mq_base->regs->FP.pin_output_select_1 =
		(mq_base->regs->FP.pin_output_select_1 & 0xff000000) |
		x | (x << 8) | (x << 16);

	return 0;
}
Ejemplo n.º 4
0
static inline u32 mcspi_read_reg(struct spi_master *master,
				 int idx)
{
	struct omap2_mcspi * mcspi = class_get_devdata(&master->cdev);

	return __raw_readl(mcspi->base + idx);
}
Ejemplo n.º 5
0
static ssize_t omap_pwm_led_off_period_show(struct class_device *cdev, char *buf)
{
	struct led_classdev *led_cdev = class_get_devdata(cdev);
	struct omap_pwm_led *led = cdev_to_omap_pwm_led(led_cdev);

	return sprintf(buf, "%u\n", led->off_period) + 1;
}
Ejemplo n.º 6
0
static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
					   struct class_interface *class_intf)
{
	struct pcmcia_socket *socket = class_get_devdata(class_dev);
	int ret;

	socket = pcmcia_get_socket(socket);
	if (!socket) {
		printk(KERN_ERR "PCMCIA obtaining reference to socket %p failed\n", socket);
		return -ENODEV;
	}

	/*
	 * Ugly. But we want to wait for the socket threads to have started up.
	 * We really should let the drivers themselves drive some of this..
	 */
	msleep(250);

#ifdef CONFIG_PCMCIA_IOCTL
	init_waitqueue_head(&socket->queue);
#endif
	INIT_LIST_HEAD(&socket->devices_list);
	INIT_WORK(&socket->device_add, pcmcia_delayed_add_pseudo_device, socket);
	memset(&socket->pcmcia_state, 0, sizeof(u8));
	socket->device_count = 0;

	ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback);
	if (ret) {
		printk(KERN_ERR "PCMCIA registration PCCard core failed for socket %p\n", socket);
		pcmcia_put_socket(socket);
		return (ret);
	}

	return 0;
}
Ejemplo n.º 7
0
static inline u32 mcspi_read_cs_reg(const struct spi_device *spi,
				    int idx)
{
	struct omap2_mcspi * mcspi = class_get_devdata(&spi->master->cdev);

	return __raw_readl(mcspi->base + spi->chip_select * 0x14 + idx);
}
Ejemplo n.º 8
0
static inline void mcspi_write_cs_reg(const struct spi_device *spi,
				      int idx, u32 val)
{
	struct omap2_mcspi * mcspi = class_get_devdata(&spi->master->cdev);

	__raw_writel(val, mcspi->base + spi->chip_select * 0x14 + idx);
}
Ejemplo n.º 9
0
static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, size_t count)
{
	struct pcmcia_socket *s = class_get_devdata(class_dev);
	unsigned long start_addr, end_addr;
	unsigned int add = ADD_MANAGED_RESOURCE;
	ssize_t ret = 0;

	ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
	if (ret != 2) {
		ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
		add = REMOVE_MANAGED_RESOURCE;
		if (ret != 2) {
			ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr);
			add = ADD_MANAGED_RESOURCE;
			if (ret != 2)
				return -EINVAL;
		}
	}
	if (end_addr < start_addr)
		return -EINVAL;

	ret = adjust_memory(s, add, start_addr, end_addr);
	if (!ret)
		s->resource_setup_new = 1;

	return ret ? ret : count;
}
Ejemplo n.º 10
0
static inline void mcspi_write_reg(struct spi_master *master,
				   int idx, u32 val)
{
	struct omap2_mcspi * mcspi = class_get_devdata(&master->cdev);

	__raw_writel(val, mcspi->base + idx);
}
Ejemplo n.º 11
0
static int 
roverp5p_backlight_get_power (struct backlight_device *bd)
{
	struct mediaq11xx_base *mq_base = class_get_devdata (&bd->class_dev);

	debug_func ("\n");

	return mq_base->get_GPIO (mq_base, 64) ? 0 : 4;
}
Ejemplo n.º 12
0
static ssize_t led_delay_off_show(struct class_device *dev, char *buf)
{
	struct led_classdev *led_cdev = class_get_devdata(dev);
	struct hwtimer_data *timer_data = led_cdev->trigger_data;

	sprintf(buf, "%lu\n", timer_data->delay_off);

	return strlen(buf) + 1;
}
Ejemplo n.º 13
0
static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev)
{
	struct pcmcia_socket *s = class_get_devdata(class_dev);
	struct class_device_attribute **attr;

	if (s->resource_ops != &pccard_nonstatic_ops)
		return;

	for (attr = pccard_rsrc_attributes; *attr; attr++)
		class_device_remove_file(class_dev, *attr);
}
Ejemplo n.º 14
0
static ssize_t led_brightness_show(struct class_device *dev, char *buf)
{
	struct led_classdev *led_cdev = class_get_devdata(dev);
	ssize_t ret = 0;

	/* no lock needed for this */
	sprintf(buf, "%u\n", led_cdev->brightness);
	ret = strlen(buf) + 1;

	return ret;
}
Ejemplo n.º 15
0
static ssize_t name_show(struct class_device *cdev, char *buf)
{
	struct switch_dev *sdev = (struct switch_dev *)
		class_get_devdata(cdev);

	if (sdev->print_name) {
		int ret = sdev->print_name(sdev, buf);
		if (ret >= 0)
			return ret;
	}
	return sprintf(buf, "%s\n", sdev->name);
}
Ejemplo n.º 16
0
static int
aximx5_lcd_get_contrast (struct lcd_device *ld)
{
	struct mediaq11xx_base *mq_base = class_get_devdata (&ld->class_dev);
	u32 c, x;

	debug_func ("\n");

	x = (mq_base->regs->FP.pin_output_select_1 & 0x7f);
	for (c = 7; x; x >>= 1, c--)
		;
	return c;
}
Ejemplo n.º 17
0
static void pcmcia_bus_remove_socket(struct class_device *class_dev,
				     struct class_interface *class_intf)
{
	struct pcmcia_socket *socket = class_get_devdata(class_dev);

	if (!socket)
		return;

	socket->pcmcia_state.dead = 1;
	pccard_register_pcmcia(socket, NULL);

	pcmcia_put_socket(socket);

	return;
}
Ejemplo n.º 18
0
static int aximx5_lcd_get_power (struct lcd_device *ld)
{
	struct mediaq11xx_base *mq_base = class_get_devdata (&ld->class_dev);
	int lcdfp_state = mq_base->get_power (mq_base, MEDIAQ_11XX_FP_DEVICE_ID);
	int fpctl_state = mq_base->get_power (mq_base, MEDIAQ_11XX_FB_DEVICE_ID);

	debug_func ("\n");

	if (lcdfp_state == 0) {
		if (fpctl_state == 0)
			return 4;
		else
			return 2;
	}
	return 0;
}
Ejemplo n.º 19
0
static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev)
{
	struct pcmcia_socket *s = class_get_devdata(class_dev);
	struct class_device_attribute **attr;
	int ret = 0;
	if (s->resource_ops != &pccard_nonstatic_ops)
		return 0;

	for (attr = pccard_rsrc_attributes; *attr; attr++) {
		ret = class_device_create_file(class_dev, *attr);
		if (ret)
			break;
	}

	return ret;
}
Ejemplo n.º 20
0
static int __devexit omap_rtc_remove(struct platform_device *pdev)
{
	struct rtc_device	*rtc = platform_get_drvdata(pdev);;

	device_init_wakeup(&pdev->dev, 0);

	/* leave rtc running, but disable irqs */
	rtc_write(0, OMAP_RTC_INTERRUPTS_REG);

	free_irq(omap_rtc_timer, rtc);
	free_irq(omap_rtc_alarm, rtc);

	release_resource(class_get_devdata(&rtc->class_dev));
	rtc_device_unregister(rtc);
	return 0;
}
Ejemplo n.º 21
0
static ssize_t led_brightness_store(struct class_device *dev,
				const char *buf, size_t size)
{
	struct led_classdev *led_cdev = class_get_devdata(dev);
	ssize_t ret = -EINVAL;
	char *after;
	unsigned long state = simple_strtoul(buf, &after, 10);
	size_t count = after - buf;

	if (*after && isspace(*after))
		count++;

	if (count == size) {
		ret = count;
		led_set_brightness(led_cdev, state);
	}

	return ret;
}
Ejemplo n.º 22
0
static void omap2_mcspi_txrx_dma(struct spi_device *spi,
				 struct spi_transfer *xfer)
{
	struct omap2_mcspi      * mcspi;
	struct omap2_mcspi_cs   * cs = spi->controller_state;
	struct omap2_mcspi_dma  * mcspi_dma;
	unsigned int		count, c;
	unsigned long		base, tx_reg, rx_reg;
	int			word_len, data_type, element_count;
	u8			* rx;
	const u8		* tx;
	u32			l;

	mcspi = class_get_devdata(&spi->master->cdev);
	mcspi_dma = &mcspi->dma_channels[spi->chip_select];

	count = xfer->len;
	c = count;
	word_len = cs->word_len;

	l = mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCONF0);
	l &= ~OMAP2_MCSPI_CHCONF_TRM_MASK;
	if (xfer->tx_buf == NULL)
		l |= OMAP2_MCSPI_CHCONF_TRM_RX_ONLY;
	else if (xfer->rx_buf == NULL)
		l |= OMAP2_MCSPI_CHCONF_TRM_TX_ONLY;
	mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, l);

	omap2_mcspi_set_enable(spi, 1);

	base = io_v2p(mcspi->base) + spi->chip_select * 0x14;
	tx_reg = base + OMAP2_MCSPI_TX0;
	rx_reg = base + OMAP2_MCSPI_RX0;
	rx = xfer->rx_buf;
	tx = xfer->tx_buf;

	if (word_len <= 8) {
		data_type = OMAP_DMA_DATA_TYPE_S8;
		element_count = count;
	} else if (word_len <= 16) {
		data_type = OMAP_DMA_DATA_TYPE_S16;
		element_count = count >> 1;
	} else if (word_len <= 32) {
Ejemplo n.º 23
0
static int appledisplay_bl_get_brightness(struct backlight_device *bd)
{
	struct appledisplay *pdata = class_get_devdata(&bd->class_dev);
	int retval;

	retval = usb_control_msg(
		pdata->udev,
		usb_rcvctrlpipe(pdata->udev, 0),
		USB_REQ_GET_REPORT,
		USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
		ACD_USB_BRIGHTNESS,
		0,
		pdata->msgdata, 2,
		ACD_USB_TIMEOUT);

	if (retval < 0)
		return retval;
	else
		return pdata->msgdata[1];
}
Ejemplo n.º 24
0
static int 
roverp5p_backlight_set_power (struct backlight_device *bd, int state)
{
	struct mediaq11xx_base *mq_base = class_get_devdata (&bd->class_dev);

	debug_func ("state:%d\n", state);

	/* Turn off backlight power */
	if (state == 0) {
		mq_base->set_GPIO (mq_base, 64, MQ_GPIO_IN | MQ_GPIO_OUT1);
		if (PWM_PWDUTY0 & 0x3ff)
			CKEN |= CKEN0_PWM0;
		else
			CKEN &= ~CKEN0_PWM0;
	} else {
		CKEN &= ~CKEN0_PWM0;
		mq_base->set_GPIO (mq_base, 64, MQ_GPIO_IN | MQ_GPIO_OUT0);
	}
	return 0;
}
Ejemplo n.º 25
0
static ssize_t goldfish_switch_state_store(struct class_device *dev,
				   const char *buf,
				   size_t count)
{
	struct goldfish_switch  *qs = class_get_devdata(dev);
	uint32_t state;

	if (!(qs->flags & SW_FLAGS_OUTPUT))
		return -EPERM;

	if (sscanf(buf, "%d", &state) != 1)
		return -EINVAL;

	writel(state, qs->base + SW_STATE);
	qs->state = readl(qs->base + SW_STATE);
	if(state != qs->state)
		return -EINVAL;

	return count;
}
Ejemplo n.º 26
0
static int appledisplay_bl_update_status(struct backlight_device *bd)
{
	struct appledisplay *pdata = class_get_devdata(&bd->class_dev);
	int retval;

	pdata->msgdata[0] = 0x10;
	pdata->msgdata[1] = bd->props->brightness;

	retval = usb_control_msg(
		pdata->udev,
		usb_sndctrlpipe(pdata->udev, 0),
		USB_REQ_SET_REPORT,
		USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
		ACD_USB_BRIGHTNESS,
		0,
		pdata->msgdata, 2,
		ACD_USB_TIMEOUT);

	return retval;
}
Ejemplo n.º 27
0
static ssize_t led_delay_on_store(struct class_device *dev, const char *buf,
				size_t size)
{
	struct led_classdev *led_cdev = class_get_devdata(dev);
	struct timer_trig_data *timer_data = led_cdev->trigger_data;
	int ret = -EINVAL;
	char *after;
	unsigned long state = simple_strtoul(buf, &after, 10);
	size_t count = after - buf;

	if (*after && isspace(*after))
		count++;

	if (count == size) {
		timer_data->delay_on = state;
		mod_timer(&timer_data->timer, jiffies + 1);
		ret = count;
	}

	return ret;
}
Ejemplo n.º 28
0
static ssize_t show_mem_db(struct class_device *class_dev, char *buf)
{
	struct pcmcia_socket *s = class_get_devdata(class_dev);
	struct socket_data *data;
	struct resource_map *p;
	ssize_t ret = 0;

	down(&rsrc_sem);
	data = s->resource_data;

	for (p = data->mem_db.next; p != &data->mem_db; p = p->next) {
		if (ret > (PAGE_SIZE - 10))
			continue;
		ret += snprintf (&buf[ret], (PAGE_SIZE - ret - 1),
				 "0x%08lx - 0x%08lx\n",
				 ((unsigned long) p->base),
				 ((unsigned long) p->base + p->num - 1));
	}

	up(&rsrc_sem);
	return (ret);
}
Ejemplo n.º 29
0
static ssize_t omap_pwm_led_off_period_store(struct class_device *cdev,
					     const char *buf, size_t size)
{
	struct led_classdev *led_cdev = class_get_devdata(cdev);
	struct omap_pwm_led *led = cdev_to_omap_pwm_led(led_cdev);
	int ret = -EINVAL;
	unsigned long val;
	char *after;
	size_t count;

	val = simple_strtoul(buf, &after, 10);
	count = after - buf;
	if (*after && isspace(*after))
		count++;

	if (count == size) {
		led->off_period = val;
		omap_pwm_led_set_blink(led);
		ret = count;
	}

	return ret;
}
Ejemplo n.º 30
0
static ssize_t led_delay_off_store(struct class_device *dev, const char *buf,
                                   size_t size)
{
	struct led_classdev *led_cdev = class_get_devdata(dev);
	struct hwtimer_data *timer_data = led_cdev->trigger_data;
	int ret = -EINVAL;
	char *after;
	unsigned long state = simple_strtoul(buf, &after, 10);
	size_t count = after - buf;

	if (*after && isspace(*after))
		count++;

	if (count == size) {
		timer_data->delay_off = state;
		if (!timer_data->delay_on || !timer_data->delay_off)
			led_set_brightness(led_cdev, LED_OFF);
		else
			led_set_brightness(led_cdev, LED_FULL);
		ret = count;
	}

	return ret;
}