Re: [Linux-zigbee-devel] [PATCH v4] ieee802154: MRF24J40 driver
On 06/15/2012 12:31 AM, Alan Ott wrote: > Driver for the Microchip MRF24J40 802.15.4 WPAN module. > > Changes in v4 > Remove unnecessary #includes. > Fix comment style. > Fix hard-coded magic FIFO size > Fix C99 comment style. > Fix BUG_ON() for TX buffer length. > Added blank lines for readability. > use print_hex_dump() instead of printk(). > Remove magic number 192us. > remove sizeof(*devrec) in call to iee802154_alloc_device(). > rename mutex to buffer_mutex > Remove extra read of interrupt status register. The issues from Alexander which are still to be addressed are: 1. What to change the "out" labels to. 2. BUG_ON() for set_channel() Alan. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH v4] ieee802154: MRF24J40 driver
Driver for the Microchip MRF24J40 802.15.4 WPAN module. Changes in v4 Remove unnecessary #includes. Fix comment style. Fix hard-coded magic FIFO size Fix C99 comment style. Fix BUG_ON() for TX buffer length. Added blank lines for readability. use print_hex_dump() instead of printk(). Remove magic number 192us. remove sizeof(*devrec) in call to iee802154_alloc_device(). rename mutex to buffer_mutex Remove extra read of interrupt status register. --- drivers/ieee802154/Kconfig| 11 + drivers/ieee802154/Makefile |1 + drivers/ieee802154/mrf24j40.c | 780 + 3 files changed, 792 insertions(+), 0 deletions(-) create mode 100644 drivers/ieee802154/mrf24j40.c diff --git a/drivers/ieee802154/Kconfig b/drivers/ieee802154/Kconfig index b1f0ce8..7c8fde7 100644 --- a/drivers/ieee802154/Kconfig +++ b/drivers/ieee802154/Kconfig @@ -49,3 +49,14 @@ config IEEE802154_ADF7242 tristate "ADF7242 transceiver driver" depends on IEEE802154_DRIVERS && MAC802154 depends on SPI + +config IEEE802154_MRF24J40 + tristate "Microchip MRF24J40 transceiver driver" + depends on IEEE802154_DRIVERS && MAC802154 + depends on SPI + ---help--- + Say Y here to enable the MRF24J20 SPI 802.15.4 wireless + controller. + + This driver can also be built as a module. To do so, say M here. + the module will be called 'mrf24j40'. diff --git a/drivers/ieee802154/Makefile b/drivers/ieee802154/Makefile index 54efc02..f060d51 100644 --- a/drivers/ieee802154/Makefile +++ b/drivers/ieee802154/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_IEEE802154_SERIAL) += serial.o obj-$(CONFIG_IEEE802154_AT86RF230) += at86rf230.o obj-$(CONFIG_IEEE802154_CC2420) += cc2420.o obj-$(CONFIG_IEEE802154_ADF7242) += adf7242.o +obj-$(CONFIG_IEEE802154_MRF24J40) += mrf24j40.o diff --git a/drivers/ieee802154/mrf24j40.c b/drivers/ieee802154/mrf24j40.c new file mode 100644 index 000..c3e63fb --- /dev/null +++ b/drivers/ieee802154/mrf24j40.c @@ -0,0 +1,780 @@ +/* + * Driver for Microchip MRF24J40 802.15.4 Wireless-PAN Networking controller + * + * Copyright (C) 2012 Alan Ott + *Signal 11 Software + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include + +/* MRF24J40 Short Address Registers */ +#define REG_RXMCR0x00 /* Receive MAC control */ +#define REG_PANIDL 0x01 /* PAN ID (low) */ +#define REG_PANIDH 0x02 /* PAN ID (high) */ +#define REG_SADRL0x03 /* Short address (low) */ +#define REG_SADRH0x04 /* Short address (high) */ +#define REG_EADR00x05 /* Long address (low) (high is EADR7) */ +#define REG_TXMCR0x11 /* Transmit MAC control */ +#define REG_PACON0 0x16 /* Power Amplifier Control */ +#define REG_PACON1 0x17 /* Power Amplifier Control */ +#define REG_PACON2 0x18 /* Power Amplifier Control */ +#define REG_TXNCON 0x1B /* Transmit Normal FIFO Control */ +#define REG_TXSTAT 0x24 /* TX MAC Status Register */ +#define REG_SOFTRST 0x2A /* Soft Reset */ +#define REG_TXSTBL 0x2E /* TX Stabilization */ +#define REG_INTSTAT 0x31 /* Interrupt Status */ +#define REG_INTCON 0x32 /* Interrupt Control */ +#define REG_RFCTL0x36 /* RF Control Mode Register */ +#define REG_BBREG1 0x39 /* Baseband Registers */ +#define REG_BBREG2 0x3A /* */ +#define REG_BBREG6 0x3E /* */ +#define REG_CCAEDTH 0x3F /* Energy Detection Threshold */ + +/* MRF24J40 Long Address Registers */ +#define REG_RFCON0 0x200 /* RF Control Registers */ +#define REG_RFCON1 0x201 +#define REG_RFCON2 0x202 +#define REG_RFCON3 0x203 +#define REG_RFCON5 0x205 +#define REG_RFCON6 0x206 +#define REG_RFCON7 0x207 +#define REG_RFCON8 0x208 +#define REG_RSSI 0x210 +#define REG_SLPCON00x211 /* Sleep Clock Control Registers */ +#define REG_SLPCON10x220 +#define REG_WAKETIMEL 0x222 /* Wake-up Time Match Value Low */ +#define REG_WAKETIMEH 0x223 /* Wake-up Time Match Value High */ +#define REG_RX_FIFO0x300 /* Receive FIFO */ + +/* Device configuration: Only channels 11-26 on page 0 are supported. */ +#define MRF24J40_CHAN_MIN 11 +#define MRF24J40_CHAN_MAX 26 +#define CHANNEL_MASK (((u32)1 << (MRF24J40_CHAN_MAX + 1)) \ +
Re: [Linux-zigbee-devel] [PATCH v3] ieee802154: MRF24J40 driver
On 06/14/2012 06:23 PM, Alan Ott wrote: > On 06/14/2012 03:22 AM, Alexander Smirnov wrote: >> 2012/6/14 Alan Ott : >>> + >>> + /* Get the length of the data in the RX FIFO. */ >>> + ret = read_long_reg(devrec, REG_RX_FIFO, &val); >>> + if (ret) >>> + goto out; >>> + >>> + if (val > 143) { >> What's the magic number? >> > The comment right below it describes it. Should I move that comment up > to before the if statement? Upon further inspection, you're right, this is messed up. Alan. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
Re: [Linux-zigbee-devel] [PATCH v3] ieee802154: MRF24J40 driver
Hi Alexander, Thanks for the notes. Responses inline: On 06/14/2012 03:22 AM, Alexander Smirnov wrote: > Hi, > > just several trivial notes: > > 2012/6/14 Alan Ott : >> Driver for the Microchip MRF24J40 802.15.4 WPAN module. >> >> --- >> >> Changes in v3: >> changed MAX_SPEED logic. >> change all __u8 and __u16 to u8 and u16 >> make read_short_reg() return status and take value pointer as parameter. >> change read_long_reg() to return status and take value pointer as a >> parameter. >> eliminate unnecessary casting. >> Fixed debugging printouts. >> Added additional TODO question >> --- >> drivers/ieee802154/Kconfig| 11 + >> drivers/ieee802154/Makefile |1 + >> drivers/ieee802154/mrf24j40.c | 784 >> + >> 3 files changed, 796 insertions(+), 0 deletions(-) >> create mode 100644 drivers/ieee802154/mrf24j40.c >> >> diff --git a/drivers/ieee802154/Kconfig b/drivers/ieee802154/Kconfig >> index b1f0ce8..7c8fde7 100644 >> --- a/drivers/ieee802154/Kconfig >> +++ b/drivers/ieee802154/Kconfig >> @@ -49,3 +49,14 @@ config IEEE802154_ADF7242 >>tristate "ADF7242 transceiver driver" >>depends on IEEE802154_DRIVERS && MAC802154 >>depends on SPI >> + >> +config IEEE802154_MRF24J40 >> + tristate "Microchip MRF24J40 transceiver driver" >> + depends on IEEE802154_DRIVERS && MAC802154 >> + depends on SPI >> + ---help--- >> + Say Y here to enable the MRF24J20 SPI 802.15.4 wireless >> + controller. >> + >> + This driver can also be built as a module. To do so, say M here. >> + the module will be called 'mrf24j40'. >> diff --git a/drivers/ieee802154/Makefile b/drivers/ieee802154/Makefile >> index 54efc02..f060d51 100644 >> --- a/drivers/ieee802154/Makefile >> +++ b/drivers/ieee802154/Makefile >> @@ -4,3 +4,4 @@ obj-$(CONFIG_IEEE802154_SERIAL) += serial.o >> obj-$(CONFIG_IEEE802154_AT86RF230) += at86rf230.o >> obj-$(CONFIG_IEEE802154_CC2420) += cc2420.o >> obj-$(CONFIG_IEEE802154_ADF7242) += adf7242.o >> +obj-$(CONFIG_IEEE802154_MRF24J40) += mrf24j40.o >> diff --git a/drivers/ieee802154/mrf24j40.c b/drivers/ieee802154/mrf24j40.c >> new file mode 100644 >> index 000..a610c8a >> --- /dev/null >> +++ b/drivers/ieee802154/mrf24j40.c >> @@ -0,0 +1,784 @@ >> +/* >> + * Driver for Microchip MRF24J40 802.15.4 Wireless-PAN Networking controller >> + * >> + * Copyright (C) 2012 Alan Ott >> + *Signal 11 Software >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + * GNU General Public License for more details. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program; if not, write to the Free Software >> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + > Do you really need all these headers? > At one point it seemed like I did, but I just did some testing and it looks like I can get it down to: #include #include #include #include #include >> +/* MRF24J40 Short Address Registers */ >> +#define REG_RXMCR0x00 /* Receive MAC control */ >> +#define REG_PANIDL 0x01 /* PAN ID (low) */ >> +#define REG_PANIDH 0x02 /* PAN ID (high) */ >> +#define REG_SADRL0x03 /* Short address (low) */ >> +#define REG_SADRH0x04 /* Short address (high) */ >> +#define REG_EADR00x05 /* Long address (low) (high is EADR7) */ >> +#define REG_TXMCR0x11 /* Transmit MAC control */ >> +#define REG_PACON0 0x16 /* Power Amplifier Control */ >> +#define REG_PACON1 0x17 /* Power Amplifier Control */ >> +#define REG_PACON2 0x18 /* Power Amplifier Control */ >> +#define REG_TXNCON 0x1B /* Transmit Normal FIFO Control */ >> +#define REG_TXSTAT 0x24 /* TX MAC Status Register */ >> +#define REG_SOFTRST 0x2A /* Soft Reset */ >> +#define REG_TXSTBL 0x2E /* TX Stabilization */ >> +#define REG_INTSTAT 0x31 /* Interrupt Status */ >> +#define REG_INTCON 0x32 /* Interrupt Control */ >> +#define REG_RFCTL0x36 /* RF Control Mode Register */ >> +#define REG_BBREG1 0x39 /* Baseband Registers */ >> +#define REG_BBREG2 0x3A /* */ >> +#define REG_BBREG6 0x3E /* */ >> +#define REG_CCAEDTH 0x3F /* Energy Detection Threshold */ >> + >> +/* MRF24J40 Long Address Registers */ >> +#define REG_RFCON0 0x200 /* RF Control
Re: [Linux-zigbee-devel] [PATCH v3] ieee802154: MRF24J40 driver
Hi, just several trivial notes: 2012/6/14 Alan Ott : > Driver for the Microchip MRF24J40 802.15.4 WPAN module. > > --- > > Changes in v3: > changed MAX_SPEED logic. > change all __u8 and __u16 to u8 and u16 > make read_short_reg() return status and take value pointer as parameter. > change read_long_reg() to return status and take value pointer as a > parameter. > eliminate unnecessary casting. > Fixed debugging printouts. > Added additional TODO question > --- > drivers/ieee802154/Kconfig | 11 + > drivers/ieee802154/Makefile | 1 + > drivers/ieee802154/mrf24j40.c | 784 > + > 3 files changed, 796 insertions(+), 0 deletions(-) > create mode 100644 drivers/ieee802154/mrf24j40.c > > diff --git a/drivers/ieee802154/Kconfig b/drivers/ieee802154/Kconfig > index b1f0ce8..7c8fde7 100644 > --- a/drivers/ieee802154/Kconfig > +++ b/drivers/ieee802154/Kconfig > @@ -49,3 +49,14 @@ config IEEE802154_ADF7242 > tristate "ADF7242 transceiver driver" > depends on IEEE802154_DRIVERS && MAC802154 > depends on SPI > + > +config IEEE802154_MRF24J40 > + tristate "Microchip MRF24J40 transceiver driver" > + depends on IEEE802154_DRIVERS && MAC802154 > + depends on SPI > + ---help--- > + Say Y here to enable the MRF24J20 SPI 802.15.4 wireless > + controller. > + > + This driver can also be built as a module. To do so, say M here. > + the module will be called 'mrf24j40'. > diff --git a/drivers/ieee802154/Makefile b/drivers/ieee802154/Makefile > index 54efc02..f060d51 100644 > --- a/drivers/ieee802154/Makefile > +++ b/drivers/ieee802154/Makefile > @@ -4,3 +4,4 @@ obj-$(CONFIG_IEEE802154_SERIAL) += serial.o > obj-$(CONFIG_IEEE802154_AT86RF230) += at86rf230.o > obj-$(CONFIG_IEEE802154_CC2420) += cc2420.o > obj-$(CONFIG_IEEE802154_ADF7242) += adf7242.o > +obj-$(CONFIG_IEEE802154_MRF24J40) += mrf24j40.o > diff --git a/drivers/ieee802154/mrf24j40.c b/drivers/ieee802154/mrf24j40.c > new file mode 100644 > index 000..a610c8a > --- /dev/null > +++ b/drivers/ieee802154/mrf24j40.c > @@ -0,0 +1,784 @@ > +/* > + * Driver for Microchip MRF24J40 802.15.4 Wireless-PAN Networking controller > + * > + * Copyright (C) 2012 Alan Ott > + * Signal 11 Software > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + Do you really need all these headers? > +/* MRF24J40 Short Address Registers */ > +#define REG_RXMCR 0x00 /* Receive MAC control */ > +#define REG_PANIDL 0x01 /* PAN ID (low) */ > +#define REG_PANIDH 0x02 /* PAN ID (high) */ > +#define REG_SADRL 0x03 /* Short address (low) */ > +#define REG_SADRH 0x04 /* Short address (high) */ > +#define REG_EADR0 0x05 /* Long address (low) (high is EADR7) */ > +#define REG_TXMCR 0x11 /* Transmit MAC control */ > +#define REG_PACON0 0x16 /* Power Amplifier Control */ > +#define REG_PACON1 0x17 /* Power Amplifier Control */ > +#define REG_PACON2 0x18 /* Power Amplifier Control */ > +#define REG_TXNCON 0x1B /* Transmit Normal FIFO Control */ > +#define REG_TXSTAT 0x24 /* TX MAC Status Register */ > +#define REG_SOFTRST 0x2A /* Soft Reset */ > +#define REG_TXSTBL 0x2E /* TX Stabilization */ > +#define REG_INTSTAT 0x31 /* Interrupt Status */ > +#define REG_INTCON 0x32 /* Interrupt Control */ > +#define REG_RFCTL 0x36 /* RF Control Mode Register */ > +#define REG_BBREG1 0x39 /* Baseband Registers */ > +#define REG_BBREG2 0x3A /* */ > +#define REG_BBREG6 0x3E /* */ > +#define REG_CCAEDTH 0x3F /* Energy Detection Threshold */ > + > +/* MRF24J40 Long Address Registers */ > +#define REG_RFCON0 0x200 /* RF Control Registers */ > +#define REG_RFCON1 0x201 > +#define REG_RFCON2 0x202 > +#define REG_RFCON3 0x203 > +#define REG_RFCON5 0x205 > +#define REG_RFCON6 0x206 > +#define REG_RFCON7 0x207 > +#define REG_RFCON8 0x208 > +#define REG_RSSI 0x210 > +#define REG_SLPCON0 0x211 /* Sleep Clock Control Registers */ > +#define REG_SLPCON1 0x220 > +#define REG_WAKET