Add support for the poweroff on calypso phones
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4520 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f58011c8bf
commit
ee7d6789b7
@ -46,8 +46,8 @@ CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c \
|
|||||||
up_interruptcontext.c up_prefetchabort.c up_releasepending.c \
|
up_interruptcontext.c up_prefetchabort.c up_releasepending.c \
|
||||||
up_releasestack.c up_reprioritizertr.c up_schedulesigaction.c \
|
up_releasestack.c up_reprioritizertr.c up_schedulesigaction.c \
|
||||||
up_sigdeliver.c up_syscall.c up_unblocktask.c \
|
up_sigdeliver.c up_syscall.c up_unblocktask.c \
|
||||||
up_undefinedinsn.c up_usestack.c
|
up_undefinedinsn.c up_usestack.c calypso_power.c
|
||||||
|
|
||||||
CHIP_ASRCS = calypso_lowputc.S
|
CHIP_ASRCS = calypso_lowputc.S
|
||||||
CHIP_CSRCS = calypso_irq.c calypso_timer.c calypso_heap.c \
|
CHIP_CSRCS = calypso_irq.c calypso_timer.c calypso_heap.c \
|
||||||
calypso_serial.c clock.c
|
calypso_serial.c calypso_spi.c clock.c
|
||||||
|
18
arch/arm/src/calypso/calypso_power.c
Normal file
18
arch/arm/src/calypso/calypso_power.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <nuttx/spi.h>
|
||||||
|
|
||||||
|
int board_power_off(void)
|
||||||
|
{
|
||||||
|
uint16_t tx;
|
||||||
|
struct spi_dev_s *spi = up_spiinitialize(0);
|
||||||
|
|
||||||
|
SPI_SETBITS(spi, 16);
|
||||||
|
|
||||||
|
tx = (1 << 6) | (1 << 1);
|
||||||
|
SPI_SNDBLOCK(spi, &tx, 1);
|
||||||
|
|
||||||
|
tx = (1 << 6) | (30 << 1);
|
||||||
|
SPI_SNDBLOCK(spi, &tx, 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
141
arch/arm/src/calypso/calypso_spi.c
Normal file
141
arch/arm/src/calypso/calypso_spi.c
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* calypso_spi.c
|
||||||
|
* SPI driver for TI Calypso
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Stefan Richter <ichgeh@l--putt.de>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/spi.h>
|
||||||
|
|
||||||
|
#warning "MOST OF SPI API IS INCOMPLETE! (Wrapper around Osmocom driver)"
|
||||||
|
extern void spi_init(void);
|
||||||
|
extern int spi_xfer(uint8_t dev_idx, uint8_t bitlen, const void *dout, void *din);
|
||||||
|
|
||||||
|
#ifndef CONFIG_SPI_EXCHANGE
|
||||||
|
#error "Calypso HW only supports exchange. Enable CONFIG_SPI_EXCHANGE!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct calypso_spidev_s
|
||||||
|
{
|
||||||
|
struct spi_dev_s spidev; /* External driver interface */
|
||||||
|
int nbits; /* Number of transfered bits */
|
||||||
|
|
||||||
|
#ifndef CONFIG_SPI_OWNBUS
|
||||||
|
sem_t exclsem; /* Mutual exclusion of devices */
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/* STUBS! */
|
||||||
|
#ifndef CONFIG_SPI_OWNBUS
|
||||||
|
static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
|
||||||
|
bool selected)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency)
|
||||||
|
{
|
||||||
|
return frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Osmocom wrapper */
|
||||||
|
static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
|
||||||
|
{
|
||||||
|
((FAR struct calypso_spidev_s *)dev)->nbits = nbits;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
|
||||||
|
FAR void *rxbuffer, size_t nwords)
|
||||||
|
{
|
||||||
|
FAR struct calypso_spidev_s *priv = (FAR struct calypso_spidev_s *)dev;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for(i=0; i<nwords; i++)
|
||||||
|
spi_xfer(0, priv->nbits, txbuffer+i, rxbuffer+i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
|
||||||
|
{
|
||||||
|
uint16_t buf = wd;
|
||||||
|
spi_exchange(dev, &buf, &buf, 1);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct spi_ops_s g_spiops =
|
||||||
|
{
|
||||||
|
#ifndef CONFIG_SPI_OWNBUS
|
||||||
|
.lock = spi_lock,
|
||||||
|
#endif
|
||||||
|
.select = spi_select,
|
||||||
|
.setfrequency = spi_setfrequency,
|
||||||
|
.setmode = spi_setmode,
|
||||||
|
.setbits = spi_setbits,
|
||||||
|
.status = 0,
|
||||||
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
|
.cmddata = ,
|
||||||
|
#endif
|
||||||
|
.send = spi_send,
|
||||||
|
#ifdef CONFIG_SPI_EXCHANGE
|
||||||
|
.exchange = spi_exchange,
|
||||||
|
#else
|
||||||
|
.sndblock = spi_sndblock,
|
||||||
|
.recvblock = spi_recvblock,
|
||||||
|
#endif
|
||||||
|
.registercallback = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct calypso_spidev_s g_spidev =
|
||||||
|
{
|
||||||
|
.spidev = { &g_spiops },
|
||||||
|
.nbits = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
FAR struct spi_dev_s *up_spiinitialize(int port)
|
||||||
|
{
|
||||||
|
switch(port) {
|
||||||
|
case 0: /* SPI master device */
|
||||||
|
spi_init();
|
||||||
|
return (FAR struct spi_dev_s *)&g_spidev;
|
||||||
|
case 1: /* uWire device */
|
||||||
|
return NULL;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
6
configs/compal_e88/include/power.h
Normal file
6
configs/compal_e88/include/power.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* arch/power.h
|
||||||
|
*
|
||||||
|
* Supposed to be empty
|
||||||
|
*
|
||||||
|
************************************************************************/
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# configs/c5471evm/nsh/appconfig
|
# configs/compal_e88/nsh_highram/appconfig
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
@ -33,22 +33,11 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# Path to example in apps/examples containing the user_start entry point
|
# NSH shell
|
||||||
|
|
||||||
CONFIGURED_APPS += examples/nsh
|
CONFIGURED_APPS += examples/nsh
|
||||||
|
|
||||||
# NSH library
|
|
||||||
CONFIGURED_APPS += system/readline
|
CONFIGURED_APPS += system/readline
|
||||||
CONFIGURED_APPS += nshlib
|
CONFIGURED_APPS += nshlib
|
||||||
|
|
||||||
# Networking support
|
# Path to example in apps/examples
|
||||||
|
CONFIGURED_APPS += examples/hello
|
||||||
ifeq ($(CONFIG_NET),y)
|
CONFIGURED_APPS += vsn/poweroff
|
||||||
CONFIGURED_APPS += netutils/uiplib
|
|
||||||
CONFIGURED_APPS += netutils/dhcpc
|
|
||||||
CONFIGURED_APPS += netutils/resolv
|
|
||||||
CONFIGURED_APPS += netutils/tftpc
|
|
||||||
CONFIGURED_APPS += netutils/webclient
|
|
||||||
endif
|
|
||||||
|
|
||||||
CONFIGURED_APPS += examples/hello examples/poweroff
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# configs/c5471evm/nsh/defconfig
|
# configs/c5471evm/nsh/defconfig
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@ -428,6 +428,10 @@ CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
|||||||
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for examples/hello
|
||||||
|
CONFIG_EXAMPLES_HELLO_BUILTIN=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/wget
|
# Settings for examples/wget
|
||||||
# CONFIG_EXAMPLE_WGET_URL - The URL of the file to get
|
# CONFIG_EXAMPLE_WGET_URL - The URL of the file to get
|
||||||
|
6
configs/compal_e99/include/power.h
Normal file
6
configs/compal_e99/include/power.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* arch/power.h
|
||||||
|
*
|
||||||
|
* Supposed to be empty
|
||||||
|
*
|
||||||
|
************************************************************************/
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# configs/c5471evm/nsh/appconfig
|
# configs/compal_e99/nsh_compalram/appconfig
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
@ -33,22 +33,11 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# Path to example in apps/examples containing the user_start entry point
|
# NSH shell
|
||||||
|
|
||||||
CONFIGURED_APPS += examples/nsh
|
|
||||||
|
|
||||||
# NSH library
|
|
||||||
CONFIGURED_APPS += system/readline
|
CONFIGURED_APPS += system/readline
|
||||||
CONFIGURED_APPS += nshlib
|
CONFIGURED_APPS += nshlib
|
||||||
|
CONFIGURED_APPS += examples/nsh
|
||||||
|
|
||||||
# Networking support
|
# Path to example in apps/examples
|
||||||
|
CONFIGURED_APPS += examples/hello
|
||||||
ifeq ($(CONFIG_NET),y)
|
CONFIGURED_APPS += vsn/poweroff
|
||||||
CONFIGURED_APPS += netutils/uiplib
|
|
||||||
CONFIGURED_APPS += netutils/dhcpc
|
|
||||||
CONFIGURED_APPS += netutils/resolv
|
|
||||||
CONFIGURED_APPS += netutils/tftpc
|
|
||||||
CONFIGURED_APPS += netutils/webclient
|
|
||||||
endif
|
|
||||||
|
|
||||||
CONFIGURED_APPS += examples/hello examples/poweroff
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# configs/c5471evm/nsh/defconfig
|
# configs/compal_e99/nsh_compalram/defconfig
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@ -396,6 +396,10 @@ CONFIG_NET_BROADCAST=n
|
|||||||
CONFIG_NET_DHCP_LIGHT=n
|
CONFIG_NET_DHCP_LIGHT=n
|
||||||
CONFIG_NET_RESOLV_ENTRIES=4
|
CONFIG_NET_RESOLV_ENTRIES=4
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for examples/hello
|
||||||
|
CONFIG_EXAMPLES_HELLO_BUILTIN=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/uip
|
# Settings for examples/uip
|
||||||
CONFIG_EXAMPLE_UIP_NOMAC=y
|
CONFIG_EXAMPLE_UIP_NOMAC=y
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# configs/c5471evm/nsh/appconfig
|
# configs/compal_e99/nsh_highram/appconfig
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
@ -34,9 +34,11 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# NSH shell
|
# NSH shell
|
||||||
|
CONFIGURED_APPS += examples/nsh
|
||||||
CONFIGURED_APPS += system/readline
|
CONFIGURED_APPS += system/readline
|
||||||
CONFIGURED_APPS += nshlib
|
CONFIGURED_APPS += nshlib
|
||||||
CONFIGURED_APPS += examples/nsh
|
|
||||||
|
|
||||||
# Path to example in apps/examples
|
# Path to example in apps/examples
|
||||||
CONFIGURED_APPS += examples/ostest
|
CONFIGURED_APPS += examples/hello
|
||||||
|
CONFIGURED_APPS += vsn/poweroff
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# configs/c5471evm/nsh/defconfig
|
# configs/compal_e99/nsh_highram/defconfig
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@ -428,6 +428,10 @@ CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
|||||||
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||||
CONFIG_NSH_BUILTIN_APPS=y
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for examples/hello
|
||||||
|
CONFIG_EXAMPLES_HELLO_BUILTIN=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for examples/wget
|
# Settings for examples/wget
|
||||||
# CONFIG_EXAMPLE_WGET_URL - The URL of the file to get
|
# CONFIG_EXAMPLE_WGET_URL - The URL of the file to get
|
||||||
@ -473,7 +477,3 @@ CONFIG_PTHREAD_STACK_MIN=256
|
|||||||
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
||||||
CONFIG_HEAP_BASE=
|
CONFIG_HEAP_BASE=
|
||||||
CONFIG_HEAP_SIZE=
|
CONFIG_HEAP_SIZE=
|
||||||
|
|
||||||
# Application configuration
|
|
||||||
CONFIG_EXAMPLES_OSTEST_BUILTIN=y
|
|
||||||
CONFIG_APPS_DIR="../apps"
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/nuttx/spi.h
|
* include/nuttx/spi.h
|
||||||
*
|
*
|
||||||
* Copyright(C) 2008-2011 Gregory Nutt. All rights reserved.
|
* Copyright(C) 2008-2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -33,8 +33,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __NUTTX_SPI_H
|
#ifndef __INCLUDE_NUTTX_SPI_H
|
||||||
#define __NUTTX_SPI_H
|
#define __INCLUDE_NUTTX_SPI_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@ -87,7 +87,7 @@
|
|||||||
#ifndef CONFIG_SPI_OWNBUS
|
#ifndef CONFIG_SPI_OWNBUS
|
||||||
# define SPI_LOCK(d,l) (d)->ops->lock(d,l)
|
# define SPI_LOCK(d,l) (d)->ops->lock(d,l)
|
||||||
#else
|
#else
|
||||||
# define SPI_LOCK(d,l)
|
# define SPI_LOCK(d,l) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -441,4 +441,4 @@ EXTERN FAR struct spi_dev_s *up_spiinitialize(int port);
|
|||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* __NUTTX_SPI_H */
|
#endif /* __INCLUDE_NUTTX_SPI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user