Example #1
0
static struct bbc_i2c_bus * __init attach_one_i2c(struct of_device *op, int index)
{
	struct bbc_i2c_bus *bp;
	struct device_node *dp;
	int entry;

	bp = kzalloc(sizeof(*bp), GFP_KERNEL);
	if (!bp)
		return NULL;

	bp->i2c_control_regs = of_ioremap(&op->resource[0], 0, 0x2, "bbc_i2c_regs");
	if (!bp->i2c_control_regs)
		goto fail;

	bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel");
	if (!bp->i2c_bussel_reg)
		goto fail;

	bp->waiting = 0;
	init_waitqueue_head(&bp->wq);
	if (request_irq(op->irqs[0], bbc_i2c_interrupt,
			IRQF_SHARED, "bbc_i2c", bp))
		goto fail;

	bp->index = index;
	bp->op = op;

	spin_lock_init(&bp->lock);

	entry = 0;
	for (dp = op->node->child;
	     dp && entry < 8;
	     dp = dp->sibling, entry++) {
		struct of_device *child_op;

		child_op = of_find_device_by_node(dp);
		bp->devs[entry].device = child_op;
		bp->devs[entry].client_claimed = 0;
	}

	writeb(I2C_PCF_PIN, bp->i2c_control_regs + 0x0);
	bp->own = readb(bp->i2c_control_regs + 0x01);
	writeb(I2C_PCF_PIN | I2C_PCF_ES1, bp->i2c_control_regs + 0x0);
	bp->clock = readb(bp->i2c_control_regs + 0x01);

	printk(KERN_INFO "i2c-%d: Regs at %p, %d devices, own %02x, clock %02x.\n",
	       bp->index, bp->i2c_control_regs, entry, bp->own, bp->clock);

	reset_one_i2c(bp);

	return bp;

fail:
	if (bp->i2c_bussel_reg)
		of_iounmap(&op->resource[1], bp->i2c_bussel_reg, 1);
	if (bp->i2c_control_regs)
		of_iounmap(&op->resource[0], bp->i2c_control_regs, 2);
	kfree(bp);
	return NULL;
}
Example #2
0
static int __devinit bw2_init_one(struct of_device *op)
{
	struct device_node *dp = op->node;
	struct all_info *all;
	int linebytes, err;

	all = kzalloc(sizeof(*all), GFP_KERNEL);
	if (!all)
		return -ENOMEM;

	spin_lock_init(&all->par.lock);

	all->par.physbase = op->resource[0].start;
	all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;

	sbusfb_fill_var(&all->info.var, dp->node, 1);
	linebytes = of_getintprop_default(dp, "linebytes",
					  all->info.var.xres);

	all->info.var.red.length = all->info.var.green.length =
		all->info.var.blue.length = all->info.var.bits_per_pixel;
	all->info.var.red.offset = all->info.var.green.offset =
		all->info.var.blue.offset = 0;

	all->par.regs = of_ioremap(&op->resource[0], BWTWO_REGISTER_OFFSET,
				   sizeof(struct bw2_regs), "bw2 regs");

	if (!of_find_property(dp, "width", NULL))
		bw2_do_default_mode(&all->par, &all->info, &linebytes);

	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);

	all->info.flags = FBINFO_DEFAULT;
	all->info.fbops = &bw2_ops;

	all->info.screen_base =
		sbus_ioremap(&op->resource[0], 0, all->par.fbsize, "bw2 ram");
	all->info.par = &all->par;

	bw2_blank(0, &all->info);

	bw2_init_fix(&all->info, linebytes);

	err= register_framebuffer(&all->info);
	if (err < 0) {
		of_iounmap(all->par.regs, sizeof(struct bw2_regs));
		of_iounmap(all->info.screen_base, all->par.fbsize);
		kfree(all);
		return err;
	}

	dev_set_drvdata(&op->dev, all);

	printk("%s: bwtwo at %lx:%lx\n",
	       dp->full_name,
	       all->par.which_io, all->par.physbase);

	return 0;
}
Example #3
0
static void cg14_unmap_regs(struct all_info *all)
{
	if (all->par.regs)
		of_iounmap(all->par.regs, sizeof(struct cg14_regs));
	if (all->par.clut)
		of_iounmap(all->par.clut, sizeof(struct cg14_clut));
	if (all->par.cursor)
		of_iounmap(all->par.cursor, sizeof(struct cg14_cursor));
	if (all->info.screen_base)
		of_iounmap(all->info.screen_base, all->par.fbsize);
}
Example #4
0
static void tcx_unmap_regs(struct all_info *all)
{
	if (all->par.tec)
		of_iounmap(all->par.tec, sizeof(struct tcx_tec));
	if (all->par.thc)
		of_iounmap(all->par.thc, sizeof(struct tcx_thc));
	if (all->par.bt)
		of_iounmap(all->par.bt, sizeof(struct bt_regs));
	if (all->par.cplane)
		of_iounmap(all->par.cplane, all->par.fbsize * sizeof(u32));
	if (all->info.screen_base)
		of_iounmap(all->info.screen_base, all->par.fbsize);
}
Example #5
0
File: bw2.c Project: 3null/linux
static int bw2_remove(struct platform_device *op)
{
	struct fb_info *info = dev_get_drvdata(&op->dev);
	struct bw2_par *par = info->par;

	unregister_framebuffer(info);

	of_iounmap(&op->resource[0], par->regs, sizeof(struct bw2_regs));
	of_iounmap(&op->resource[0], info->screen_base, info->fix.smem_len);

	framebuffer_release(info);

	return 0;
}
Example #6
0
static int __devexit bw2_remove(struct of_device *dev)
{
	struct all_info *all = dev_get_drvdata(&dev->dev);

	unregister_framebuffer(&all->info);

	of_iounmap(all->par.regs, sizeof(struct bw2_regs));
	of_iounmap(all->info.screen_base, all->par.fbsize);

	kfree(all);

	dev_set_drvdata(&dev->dev, NULL);

	return 0;
}
Example #7
0
static void cg14_unmap_regs(struct of_device *op, struct fb_info *info,
			    struct cg14_par *par)
{
	if (par->regs)
		of_iounmap(&op->resource[0],
			   par->regs, sizeof(struct cg14_regs));
	if (par->clut)
		of_iounmap(&op->resource[0],
			   par->clut, sizeof(struct cg14_clut));
	if (par->cursor)
		of_iounmap(&op->resource[0],
			   par->cursor, sizeof(struct cg14_cursor));
	if (info->screen_base)
		of_iounmap(&op->resource[1],
			   info->screen_base, info->fix.smem_len);
}
Example #8
0
static int __devexit bbc_i2c_remove(struct of_device *op)
{
	struct bbc_i2c_bus *bp = dev_get_drvdata(&op->dev);

	bbc_envctrl_cleanup(bp);

	free_irq(op->irqs[0], bp);

	if (bp->i2c_bussel_reg)
		of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1);
	if (bp->i2c_control_regs)
		of_iounmap(&op->resource[1], bp->i2c_control_regs, 2);

	kfree(bp);

	return 0;
}
Example #9
0
File: tcx.c Project: 020gzh/linux
static void tcx_unmap_regs(struct platform_device *op, struct fb_info *info,
			   struct tcx_par *par)
{
	if (par->tec)
		of_iounmap(&op->resource[7],
			   par->tec, sizeof(struct tcx_tec));
	if (par->thc)
		of_iounmap(&op->resource[9],
			   par->thc, sizeof(struct tcx_thc));
	if (par->bt)
		of_iounmap(&op->resource[8],
			   par->bt, sizeof(struct bt_regs));
	if (par->cplane)
		of_iounmap(&op->resource[4],
			   par->cplane, info->fix.smem_len * sizeof(u32));
	if (info->screen_base)
		of_iounmap(&op->resource[0],
			   info->screen_base, info->fix.smem_len);
}
static int __devinit uctrl_probe(struct of_device *op,
				 const struct of_device_id *match)
{
	struct uctrl_driver *p;
	int err = -ENOMEM;

	p = kzalloc(sizeof(*p), GFP_KERNEL);
	if (!p) {
		printk(KERN_ERR "uctrl: Unable to allocate device struct.\n");
		goto out;
	}

	p->regs = of_ioremap(&op->resource[0], 0,
			     resource_size(&op->resource[0]),
			     "uctrl");
	if (!p->regs) {
		printk(KERN_ERR "uctrl: Unable to map registers.\n");
		goto out_free;
	}

	p->irq = op->irqs[0];
	err = request_irq(p->irq, uctrl_interrupt, 0, "uctrl", p);
	if (err) {
		printk(KERN_ERR "uctrl: Unable to register irq.\n");
		goto out_iounmap;
	}

	err = misc_register(&uctrl_dev);
	if (err) {
		printk(KERN_ERR "uctrl: Unable to register misc device.\n");
		goto out_free_irq;
	}

	sbus_writel(UCTRL_INTR_RXNE_REQ|UCTRL_INTR_RXNE_MSK, &p->regs->uctrl_intr);
	printk(KERN_INFO "%s: uctrl regs[0x%p] (irq %d)\n",
	       op->dev.of_node->full_name, p->regs, p->irq);
	uctrl_get_event_status(p);
	uctrl_get_external_status(p);

	dev_set_drvdata(&op->dev, p);
	global_driver = p;

out:
	return err;

out_free_irq:
	free_irq(p->irq, p);

out_iounmap:
	of_iounmap(&op->resource[0], p->regs, resource_size(&op->resource[0]));

out_free:
	kfree(p);
	goto out;
}
Example #11
0
static int __devexit uctrl_remove(struct platform_device *op)
{
	struct uctrl_driver *p = dev_get_drvdata(&op->dev);

	if (p) {
		misc_deregister(&uctrl_dev);
		free_irq(p->irq, p);
		of_iounmap(&op->resource[0], p->regs, resource_size(&op->resource[0]));
		kfree(p);
	}
	return 0;
}
Example #12
0
static int __devexit env_remove(struct platform_device *op)
{
	struct env *p = platform_get_drvdata(op);

	if (p) {
		sysfs_remove_group(&op->dev.kobj, &env_group);
		hwmon_device_unregister(p->hwmon_dev);
		of_iounmap(&op->resource[0], p->regs, REG_SIZE);
		kfree(p);
	}

	return 0;
}
static int __devinit bbc_i2c_probe(struct platform_device *op)
{
	struct bbc_i2c_bus *bp;
	int err, index = 0;

	bp = attach_one_i2c(op, index);
	if (!bp)
		return -EINVAL;

	err = bbc_envctrl_init(bp);
	if (err) {
		free_irq(op->archdata.irqs[0], bp);
		if (bp->i2c_bussel_reg)
			of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1);
		if (bp->i2c_control_regs)
			of_iounmap(&op->resource[1], bp->i2c_control_regs, 2);
		kfree(bp);
	} else {
		dev_set_drvdata(&op->dev, bp);
	}

	return err;
}
Example #14
0
static int __devexit myri_sbus_remove(struct platform_device *op)
{
	struct myri_eth *mp = dev_get_drvdata(&op->dev);
	struct net_device *net_dev = mp->dev;

	unregister_netdev(net_dev);

	free_irq(net_dev->irq, net_dev);

	if (mp->eeprom.cpuvers < CPUVERS_4_0) {
		of_iounmap(&op->resource[0], mp->regs, mp->reg_size);
	} else {
		of_iounmap(&op->resource[0], mp->cregs, PAGE_SIZE);
		of_iounmap(&op->resource[0], mp->lregs, (256 * 1024));
		of_iounmap(&op->resource[0], mp->lanai, (512 * 1024));
	}

	free_netdev(net_dev);

	dev_set_drvdata(&op->dev, NULL);

	return 0;
}
Example #15
0
static int __devexit envctrl_remove(struct of_device *op)
{
	int index;

	kthread_stop(kenvctrld_task);

	of_iounmap(&op->resource[0], i2c, 0x2);
	misc_deregister(&envctrl_dev);

	for (index = 0; index < ENVCTRL_MAX_CPU * 2; index++)
		kfree(i2c_childlist[index].tables);

	return 0;
}
Example #16
0
static int d7s_remove(struct platform_device *op)
{
	struct d7s *p = dev_get_drvdata(&op->dev);
	u8 regs = readb(p->regs);

	/* Honor OBP d7s-flipped? unless operating in solaris-compat mode */
	if (sol_compat) {
		if (p->flipped)
			regs |= D7S_FLIP;
		else
			regs &= ~D7S_FLIP;
		writeb(regs, p->regs);
	}

	misc_deregister(&d7s_miscdev);
	of_iounmap(&op->resource[0], p->regs, sizeof(u8));

	return 0;
}
Example #17
0
static int __devexit bpp_remove(struct of_device *op)
{
	struct parport *p = dev_get_drvdata(&op->dev);
	struct parport_operations *ops = p->ops;

	parport_remove_port(p);

	if (p->irq != PARPORT_IRQ_NONE) {
		parport_sunbpp_disable_irq(p);
		free_irq(p->irq, p);
	}

	of_iounmap(&op->resource[0], (void __iomem *) p->base, p->size);
	parport_put_port(p);
	kfree(ops);

	dev_set_drvdata(&op->dev, NULL);

	return 0;
}
Example #18
0
static int __devinit env_probe(struct of_device *op,
			       const struct of_device_id *match)
{
	struct env *p = kzalloc(sizeof(*p), GFP_KERNEL);
	int err = -ENOMEM;

	if (!p)
		goto out;

	spin_lock_init(&p->lock);

	p->regs = of_ioremap(&op->resource[0], 0, REG_SIZE, "pic16f747");
	if (!p->regs)
		goto out_free;

	err = sysfs_create_group(&op->dev.kobj, &env_group);
	if (err)
		goto out_iounmap;

	p->hwmon_dev = hwmon_device_register(&op->dev);
	if (IS_ERR(p->hwmon_dev)) {
		err = PTR_ERR(p->hwmon_dev);
		goto out_sysfs_remove_group;
	}

	dev_set_drvdata(&op->dev, p);
	err = 0;

out:
	return err;

out_sysfs_remove_group:
	sysfs_remove_group(&op->dev.kobj, &env_group);

out_iounmap:
	of_iounmap(&op->resource[0], p->regs, REG_SIZE);

out_free:
	kfree(p);
	goto out;
}
Example #19
0
static void leo_unmap_regs(struct of_device *op, struct fb_info *info,
			   struct leo_par *par)
{
	if (par->lc_ss0_usr)
		of_iounmap(&op->resource[0], par->lc_ss0_usr, 0x1000);
	if (par->ld_ss0)
		of_iounmap(&op->resource[0], par->ld_ss0, 0x1000);
	if (par->ld_ss1)
		of_iounmap(&op->resource[0], par->ld_ss1, 0x1000);
	if (par->lx_krn)
		of_iounmap(&op->resource[0], par->lx_krn, 0x1000);
	if (par->cursor)
		of_iounmap(&op->resource[0],
			   par->cursor, sizeof(struct leo_cursor));
	if (info->screen_base)
		of_iounmap(&op->resource[0], info->screen_base, 0x800000);
}
Example #20
0
static int __devinit d7s_probe(struct platform_device *op)
{
	struct device_node *opts;
	int err = -EINVAL;
	struct d7s *p;
	u8 regs;

	if (d7s_device)
		goto out;

	p = kzalloc(sizeof(*p), GFP_KERNEL);
	err = -ENOMEM;
	if (!p)
		goto out;

	p->regs = of_ioremap(&op->resource[0], 0, sizeof(u8), "d7s");
	if (!p->regs) {
		printk(KERN_ERR PFX "Cannot map chip registers\n");
		goto out_free;
	}

	err = misc_register(&d7s_miscdev);
	if (err) {
		printk(KERN_ERR PFX "Unable to acquire miscdevice minor %i\n",
		       D7S_MINOR);
		goto out_iounmap;
	}

	/* OBP option "d7s-flipped?" is honored as default for the
	 * device, and reset default when detached
	 */
	regs = readb(p->regs);
	opts = of_find_node_by_path("/options");
	if (opts &&
	    of_get_property(opts, "d7s-flipped?", NULL))
		p->flipped = true;

	if (p->flipped)
		regs |= D7S_FLIP;
	else
		regs &= ~D7S_FLIP;

	writeb(regs,  p->regs);

	printk(KERN_INFO PFX "7-Segment Display%s at [%s:0x%llx] %s\n",
	       op->dev.of_node->full_name,
	       (regs & D7S_FLIP) ? " (FLIPPED)" : "",
	       op->resource[0].start,
	       sol_compat ? "in sol_compat mode" : "");

	dev_set_drvdata(&op->dev, p);
	d7s_device = p;
	err = 0;

out:
	return err;

out_iounmap:
	of_iounmap(&op->resource[0], p->regs, sizeof(u8));

out_free:
	kfree(p);
	goto out;
}
Example #21
0
static int __devinit envctrl_probe(struct of_device *op,
				   const struct of_device_id *match)
{
	struct device_node *dp;
	int index, err;

	if (i2c)
		return -EINVAL;

	i2c = of_ioremap(&op->resource[0], 0, 0x2, DRIVER_NAME);
	if (!i2c)
		return -ENOMEM;

	index = 0;
	dp = op->node->child;
	while (dp) {
		if (!strcmp(dp->name, "gpio")) {
			i2c_childlist[index].i2ctype = I2C_GPIO;
			envctrl_init_i2c_child(dp, &(i2c_childlist[index++]));
		} else if (!strcmp(dp->name, "adc")) {
			i2c_childlist[index].i2ctype = I2C_ADC;
			envctrl_init_i2c_child(dp, &(i2c_childlist[index++]));
		}

		dp = dp->sibling;
	}

	/* Set device address. */
	writeb(CONTROL_PIN, i2c + PCF8584_CSR);
	writeb(PCF8584_ADDRESS, i2c + PCF8584_DATA);

	/* Set system clock and SCL frequencies. */ 
	writeb(CONTROL_PIN | CONTROL_ES1, i2c + PCF8584_CSR);
	writeb(CLK_4_43 | BUS_CLK_90, i2c + PCF8584_DATA);

	/* Enable serial interface. */
	writeb(CONTROL_PIN | CONTROL_ES0 | CONTROL_ACK, i2c + PCF8584_CSR);
	udelay(200);

	/* Register the device as a minor miscellaneous device. */
	err = misc_register(&envctrl_dev);
	if (err) {
		printk(KERN_ERR PFX "Unable to get misc minor %d\n",
		       envctrl_dev.minor);
		goto out_iounmap;
	}

	/* Note above traversal routine post-incremented 'i' to accommodate 
	 * a next child device, so we decrement before reverse-traversal of
	 * child devices.
	 */
	printk(KERN_INFO PFX "Initialized ");
	for (--index; index >= 0; --index) {
		printk("[%s 0x%lx]%s", 
			(I2C_ADC == i2c_childlist[index].i2ctype) ? "adc" : 
			((I2C_GPIO == i2c_childlist[index].i2ctype) ? "gpio" : "unknown"), 
			i2c_childlist[index].addr, (0 == index) ? "\n" : " ");
	}

	kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
	if (IS_ERR(kenvctrld_task)) {
		err = PTR_ERR(kenvctrld_task);
		goto out_deregister;
	}

	return 0;

out_deregister:
	misc_deregister(&envctrl_dev);
out_iounmap:
	of_iounmap(&op->resource[0], i2c, 0x2);
	for (index = 0; index < ENVCTRL_MAX_CPU * 2; index++)
		kfree(i2c_childlist[index].tables);

	return err;
}
static inline void apc_free(struct platform_device *op)
{
	of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0]));
}
Example #23
0
static int __devinit bpp_probe(struct of_device *op, const struct of_device_id *match)
{
	struct parport_operations *ops;
	struct bpp_regs __iomem *regs;
	int irq, dma, err = 0, size;
	unsigned char value_tcr;
	void __iomem *base;
	struct parport *p;

	irq = op->irqs[0];
	base = of_ioremap(&op->resource[0], 0,
			  resource_size(&op->resource[0]),
			  "sunbpp");
	if (!base)
		return -ENODEV;

	size = resource_size(&op->resource[0]);
	dma = PARPORT_DMA_NONE;

	ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
        if (!ops)
		goto out_unmap;

        memcpy (ops, &parport_sunbpp_ops, sizeof(struct parport_operations));

	dprintk(("register_port\n"));
	if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
		goto out_free_ops;

	p->size = size;
	p->dev = &op->dev;

	if ((err = request_irq(p->irq, parport_irq_handler,
			       IRQF_SHARED, p->name, p)) != 0) {
		goto out_put_port;
	}

	parport_sunbpp_enable_irq(p);

	regs = (struct bpp_regs __iomem *)p->base;

	value_tcr = sbus_readb(&regs->p_tcr);
	value_tcr &= ~P_TCR_DIR;
	sbus_writeb(value_tcr, &regs->p_tcr);

	printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base);

	dev_set_drvdata(&op->dev, p);

	parport_announce_port(p);

	return 0;

out_put_port:
	parport_put_port(p);

out_free_ops:
	kfree(ops);

out_unmap:
	of_iounmap(&op->resource[0], base, size);

	return err;
}
Example #24
0
File: bw2.c Project: 3null/linux
static int bw2_probe(struct platform_device *op)
{
	struct device_node *dp = op->dev.of_node;
	struct fb_info *info;
	struct bw2_par *par;
	int linebytes, err;

	info = framebuffer_alloc(sizeof(struct bw2_par), &op->dev);

	err = -ENOMEM;
	if (!info)
		goto out_err;
	par = info->par;

	spin_lock_init(&par->lock);

	info->fix.smem_start = op->resource[0].start;
	par->which_io = op->resource[0].flags & IORESOURCE_BITS;

	sbusfb_fill_var(&info->var, dp, 1);
	linebytes = of_getintprop_default(dp, "linebytes",
					  info->var.xres);

	info->var.red.length = info->var.green.length =
		info->var.blue.length = info->var.bits_per_pixel;
	info->var.red.offset = info->var.green.offset =
		info->var.blue.offset = 0;

	par->regs = of_ioremap(&op->resource[0], BWTWO_REGISTER_OFFSET,
			       sizeof(struct bw2_regs), "bw2 regs");
	if (!par->regs)
		goto out_release_fb;

	if (!of_find_property(dp, "width", NULL)) {
		err = bw2_do_default_mode(par, info, &linebytes);
		if (err)
			goto out_unmap_regs;
	}

	info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres);

	info->flags = FBINFO_DEFAULT;
	info->fbops = &bw2_ops;

	info->screen_base = of_ioremap(&op->resource[0], 0,
				       info->fix.smem_len, "bw2 ram");
	if (!info->screen_base) {
		err = -ENOMEM;
		goto out_unmap_regs;
	}

	bw2_blank(FB_BLANK_UNBLANK, info);

	bw2_init_fix(info, linebytes);

	err = register_framebuffer(info);
	if (err < 0)
		goto out_unmap_screen;

	dev_set_drvdata(&op->dev, info);

	printk(KERN_INFO "%s: bwtwo at %lx:%lx\n",
	       dp->full_name, par->which_io, info->fix.smem_start);

	return 0;

out_unmap_screen:
	of_iounmap(&op->resource[0], info->screen_base, info->fix.smem_len);

out_unmap_regs:
	of_iounmap(&op->resource[0], par->regs, sizeof(struct bw2_regs));

out_release_fb:
	framebuffer_release(info);

out_err:
	return err;
}