All pastes #910252 Raw Edit

Stuff

public text v1 · immutable
·published 2008-02-19 20:55 UTC
rendered paste body
/* Bluetooth interface driver for TI BRF6150 on HX4700
 *
 * Copyright (c) 2005 SDG Systems, LLC
 *
 * 2005-04-21   Todd Blumer             Created.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/soc/asic3_base.h>
#include <linux/leds.h>

#include <asm/hardware.h>
#include <asm/arch/serial.h>
#include <asm/arch/htcblueangel-asic.h>

DEFINE_LED_TRIGGER(bluetooth_trig);

static int bluetooth_power = 0;

static void
htcblueangel_bt_configure( int state )
{
	if (state) {
		printk("Bluetooth: Powering up\n");
		asic3_set_gpio_out_a(&blueangel_asic3.dev, 1<<GPIOA_BT_PWR1_ON, 1<<GPIOA_BT_PWR1_ON);                        
		asic3_set_gpio_out_b(&blueangel_asic3.dev, 1<<GPIOB_BT_PWR2_ON, 1<<GPIOB_BT_PWR2_ON);
		led_trigger_event(bluetooth_trig, LED_FULL);                                                                    

		//enable_irq(irq);
		//set_irq_type(irq, IRQ_TYPE_EDGE_FALLING);
		//request_irq(irq, blueangel_bluetooth_irq, SA_INTERRUPT, DEVICE_NAME, NULL);
	}
	else 
	{
		printk("Bluetooth: Powering Down\n");
		asic3_set_gpio_out_a(&blueangel_asic3.dev, 1<<GPIOA_BT_PWR1_ON, 0);                                          
		asic3_set_gpio_out_b(&blueangel_asic3.dev, 1<<GPIOB_BT_PWR2_ON, 0);                                          
		led_trigger_event(bluetooth_trig, LED_OFF);
		//free_irq(irq, NULL);
		//disable_irq(irq);
	}
}

static ssize_t bluetooth_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d\n", bluetooth_power);
}

static ssize_t bluetooth_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
	unsigned int power;

	power = simple_strtoul(buf, NULL, 10);

	bluetooth_power = power != 0 ? 1 : 0;

	htcblueangel_bt_configure(bluetooth_power);

	return count;
}

static DEVICE_ATTR(bluetooth_power, 0644, bluetooth_show, bluetooth_store);

static int
htcblueangel_bt_probe( struct platform_device *pdev )
{
	printk("Blueangel: Initializing bluetooth hardware.\n");

	GPDR(GPIO42_HWRXD) &= ~(GPIO_bit(GPIO42_HWRXD));                                                             
	GPDR(GPIO43_HWTXD) |= GPIO_bit(GPIO43_HWTXD);                                                                
	GPDR(GPIO44_HWCTS) &= ~(GPIO_bit(GPIO44_HWCTS));                                                             
	GPDR(GPIO45_HWRTS) |= GPIO_bit(GPIO45_HWRTS);                                                                

	pxa_gpio_mode(GPIO42_HWRXD_MD);                                                                              
	pxa_gpio_mode(GPIO43_HWTXD_MD);                                                                              
	pxa_gpio_mode(GPIO44_HWCTS_MD);                                                                              
	pxa_gpio_mode(GPIO45_HWRTS_MD);                                                                              

	asic3_set_gpio_dir_a(&blueangel_asic3.dev, 1<<GPIOA_BT_PWR1_ON, 1<<GPIOA_BT_PWR1_ON);                        
	asic3_set_gpio_dir_b(&blueangel_asic3.dev, 1<<GPIOB_BT_PWR2_ON, 1<<GPIOB_BT_PWR2_ON);

	htcblueangel_bt_configure(bluetooth_power);

	device_create_file(&pdev->dev, &dev_attr_bluetooth_power);

	led_trigger_register_simple("bluetooth", &bluetooth_trig);
	
	return 0;
}

static int
htcblueangel_bt_remove( struct platform_device *pdev )
{

	device_remove_file(&pdev->dev, &dev_attr_bluetooth_power);

	led_trigger_unregister_simple(bluetooth_trig);
	
	return 0;
}

static struct platform_driver bt_driver = {
	.driver = {
		.name     = "blueangel-bt",
	},
	.probe    = htcblueangel_bt_probe,
	.remove   = htcblueangel_bt_remove,
};

static int __init
htcblueangel_bt_init( void )
{
	printk(KERN_NOTICE "htcblueangel Bluetooth Driver\n");
	return platform_driver_register( &bt_driver );
}

static void __exit
htcblueangel_bt_exit( void )
{
	platform_driver_unregister( &bt_driver );
}

module_init( htcblueangel_bt_init );
module_exit( htcblueangel_bt_exit );

MODULE_AUTHOR("");
MODULE_DESCRIPTION("HTC Blueangel Bluetooth Support Driver");
MODULE_LICENSE("GPL");