From: Mattias A. <mat...@us...> - 2001-06-06 14:52:32
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.177 1.178=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Check for CONFIG_BLUETOOTH_SUPPORT_BCSP instead of ..._USE_BCSP * Extracted reset ioctl code to separate function (bt_reset_phys_hw()) * Added ioctl for setting bcspmode * Removed unused code (forwarding ioctl to serial driver) * Added check in bt_feedstack if we really found an active line * Only init bcsp if enabled and not already syncronizied=20 (from separate ioctl) * Minor changes and cleanup The diff of the modified file(s): --- bluetooth.c 2001/05/30 08:01:13 1.177 +++ bluetooth.c 2001/06/06 14:52:31 1.178 @@ -82,7 +82,7 @@ #include <linux/bluetooth/sdp.h> #include <linux/bluetooth/sec_client.h> #include <linux/bluetooth/bt_errno.h> -#ifdef CONFIG_BLUETOOTH_USE_BCSP +#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP #include <linux/bluetooth/bcsp.h> #endif =20 @@ -612,10 +612,6 @@ return (SESSIONSTATE(line) =3D=3D BT_LOWERCONNECTED); } =20=09 - case BTSETSPEED: - BT_DRIVER(FNC"BTSETSPEED not implemented\n"); - break; -=20=20=20=20 case BTINITSTACK: bt_init_stack(); break; @@ -642,68 +638,7 @@ break; =20 case BTRESETPHYSICALHW: -#ifdef __CRIS__ - -#ifdef CONFIG_BLUETOOTH_CSR -#define CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH -#else -#undef CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH -#endif - -#if defined(CONFIG_BLUETOOTH_RESET_PA7) -#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) - BT_DRIVER(FNC"Resetting hardware (PA7) Active High\n"); - REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 1); - udelay(1000); - REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 0); -#else - BT_DRIVER(FNC"Resetting hardware (PA7) Active Low\n"); - REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 0); - udelay(1000); - REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 1); -#endif -#elif defined(CONFIG_BLUETOOTH_RESET_PB5) -#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) - BT_DRIVER(FNC"Resetting hardware (PB5) Active High\n"); - REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 1); - udelay(1000); - REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 0); -#else - BT_DRIVER(FNC"Resetting hardware (PB5) Active Low\n"); - REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 0); - udelay(1000); - REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 1); -#endif -#elif defined(CONFIG_BLUETOOTH_RESET_G10) -#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) - BT_DRIVER(FNC"Resetting hardware (G10) Active High\n"); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 1); - udelay(1000); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 0); -#else - BT_DRIVER(FNC"Resetting hardware (G10) Active Low\n "); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 0); - udelay(1000); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 1); -#endif -#elif defined(CONFIG_BLUETOOTH_RESET_G11) -#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) - BT_DRIVER(FNC"Resetting hardware (G11) Active High\n"); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 1); - udelay(1000); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 0); -#else - BT_DRIVER(FNC"Resetting hardware (G11) Active Low\n "); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 0); - udelay(1000); - REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 1); -#endif -#else - D_ERR(FNC"Resetting hardware : No reset pin defined\n"); -#endif -#else - BT_DRIVER(FNC"Do not know how to reset the bluetooth hardware!\n"); -#endif + bt_reset_phys_hw(); break; =20 case BTISINITIATED: @@ -1102,17 +1037,51 @@ return 0; } =20=09=09 - default:=09=09 -#if 0=09=20=20 - /* forward rest to serial driver ! */=09=09 - BT_DRIVER(FNC"forwarding ioctl 0x%x to serial driver\n", cmd); - if (sertty !=3D NULL) - return sertty->driver.ioctl(sertty, file, cmd, arg); + case BTSETBCSPMODE : + { + u8 enable; =20 - break; -#else - return -ENOIOCTLCMD; + GET_USER(tmp, (s32*)arg); + + enable =3D (u8)(tmp & 0xff); +=09=09 + BT_DRIVER("BTSETBCSPMODE : %d\n", enable); +=09=09 + bt_use_bcsp(enable); +=09=09 + return 0; + } + +#ifdef CONFIG_BLUETOOTH_CSR + + /* | ps_key (u16) | rw_mode (u16) | len (u16) | params (u16[])| */ + + case BT_CSR_PSKEY: + { + u16 u16_size =3D CSR_PSKEY_MSGHDR_SIZE + CSR_PSKEY_MAXPARAMS; + u16 msg[size]; +=09=09 + copy_from_user(msg, (u8*)arg, u16_size*sizeof(u16)); + + csr_pskey(msg[0], msg[1], &msg[3], msg[2]); +=09=09 + copy_to_user((s32*)arg, msg, u16_size*sizeof(u16)); + return 0; + } + + case BTINITBCSP: + { + printk("BTINITBCSP\n"); + if (bcsp_init() < 0) + printk("Sync failed\n"); + return 0; + } + #endif + + default:=09=09 + return -ENOIOCTLCMD; + } return 0; #undef FNC @@ -1316,7 +1285,75 @@ printk("bt_tty_wakeup : not done\n"); } =20 +void bt_reset_phys_hw(void) +{ +#define FNC __FUNCTION__": "=09 +#ifdef __CRIS__ +=09 +#ifdef CONFIG_BLUETOOTH_CSR +#define CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH +#else +#undef CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH +#endif =20 +#if defined(CONFIG_BLUETOOTH_RESET_PA7) +#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) + BT_DRIVER(FNC"Resetting hardware (PA7) Active High\n"); + REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 1); + udelay(1000); + REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 0); +#else + BT_DRIVER(FNC"Resetting hardware (PA7) Active Low\n"); + REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 0); + udelay(1000); + REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, 7, 1); +#endif +#elif defined(CONFIG_BLUETOOTH_RESET_PB5) +#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) + BT_DRIVER(FNC"Resetting hardware (PB5) Active High\n"); + REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 1); + udelay(1000); + REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 0); +#else + BT_DRIVER(FNC"Resetting hardware (PB5) Active Low\n"); + REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 0); + udelay(1000); + REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 5, 1); +#endif +#elif defined(CONFIG_BLUETOOTH_RESET_G10) +#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) + BT_DRIVER(FNC"Resetting hardware (G10) Active High\n"); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 1); + udelay(1000); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 0); +#else + BT_DRIVER(FNC"Resetting hardware (G10) Active Low\n "); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 0); + udelay(1000); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 1); +#endif +#elif defined(CONFIG_BLUETOOTH_RESET_G11) +#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) + BT_DRIVER(FNC"Resetting hardware (G11) Active High\n"); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 1); + udelay(1000); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 0); +#else + BT_DRIVER(FNC"Resetting hardware (G11) Active Low\n "); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 0); + udelay(1000); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 1); +#endif +#else + D_ERR(FNC"Resetting hardware : No reset pin defined\n"); +#endif +#else + BT_DRIVER(FNC"Do not know how to reset the bluetooth hardware!\n"); +#endif +#undef FNC +} + + /************************/ /* glue layer functions */ /************************/ @@ -1328,7 +1365,7 @@ =20 s32 bt_write_lower_driver(u8 *data, s32 len) -#ifdef CONFIG_BLUETOOTH_USE_BCSP +#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP { if (bt_use_bcsp(-1)) return bcsp_write_top(data, len); @@ -1540,7 +1577,10 @@ check_line =3D 0; } =20 - /* found an active */ + /* check if we really found an active */ + if (nbr_checked > BT_NBR_DATAPORTS) + return; + //BT_DATA("bt_feedstack : wakeup line %d !\n", check_line); upper_tty =3D GET_UPPERTTY(check_line); bt_ctrl.tty_last_unthrottled =3D check_line; @@ -1664,7 +1704,7 @@ static void bt_receive_data(u8* data, u32 count) { -#ifdef CONFIG_BLUETOOTH_USE_BCSP +#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP if (bt_use_bcsp(-1)) bcsp_receive_lower(data, count); else @@ -2308,6 +2348,7 @@ s32 bt_use_bcsp(s32 new_use_bcsp) { +/* default val */ #ifdef CONFIG_BLUETOOTH_USE_BCSP static s32 use_bcsp =3D 1; #else @@ -2317,14 +2358,12 @@ =20 if (new_use_bcsp >=3D 0) { -#ifdef CONFIG_BLUETOOTH_USE_BCSP +#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP use_bcsp =3D new_use_bcsp; #endif } - return old; } - void bt_init_stack(void) { @@ -2356,7 +2395,10 @@ =20 DSYS("Current HW: %s\n", bt_hw_vendor()); =20 -#ifdef CONFIG_BLUETOOTH_USE_BCSP + btmem_init(); + +#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP + if (bt_use_bcsp(-1) && !bcsp_issyncronized()) bcsp_init(); #endif hci_init(); @@ -2369,7 +2411,7 @@ sdp_init(1); /* For now always init as server */ tcs_init(); #endif - btmem_init(); + bt_stack_initiated =3D 1; bt_stat.bytes_received =3D 0; bt_stat.bytes_sent =3D 0; @@ -2755,12 +2797,15 @@ tcs_shutdown(); l2cap_shutdown(); hci_shutdown(); - btmem_shutdown(); - bt_stack_initiated =3D 0; =20 -#ifdef CONFIG_BLUETOOTH_USE_BCSP +#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP + if (bt_use_bcsp(-1)) bcsp_shutdown(); #endif + + btmem_shutdown(); + + bt_stack_initiated =3D 0; =20=09 if (tmp_bt_buf) { free_page((unsigned long) tmp_bt_buf); |