OK. It did work in this (ugly) way: USB1 USB2 ON ON ./devmem2 0x1c2090c w 0x180078 ON OFF ./devmem2 0x1c2090c w 0x180038 OFF ON ./devmem2 0x1c2090c w 0x180070 OFF OFF ./devmem2 0x1c2090c w 0x180030
USB1 is (for me) the upper usb port. 0x1c2090c is the memory address of Port H Data register and the last argument is the word to write in that register. You can get devmem2 (direct access to memory using /dev/mem) on the web or attached here (binary compiled for A10 here: https://dl.dropboxusercontent.com/u/848639/keep/devmem2). NOTE that this works on the Cubieboard (A10) only, since it provides an electronic switch on both usb ports. Maybe you can use a similar approach on other boards with similar switches on board. Hope it helps, Vincenzo Il giorno martedì 24 settembre 2013 08:01:25 UTC+2, mahdi taheri ha scritto: > > > <https://lh3.googleusercontent.com/-90PNhmAkyYg/UkEqsKCtLBI/AAAAAAAAABQ/LV6U_uuN6Jk/s1600/UsbPowerControl.png> > > > On Monday, September 23, 2013 10:59:34 PM UTC-7, [email protected] wrote: >> >> I want to control the power off my Usb Device conected to cubieboard >> (power off - power on the device by usb1-drv or usb2-drv ) >> >> I googled a lot and find this article >> http://e2e.ti.com/support/arm/sitara_arm/f/791/t/270060.aspx >> but it is not for cubie can anybody help me for this issue? >> >> according to attached image it must be a way to control USB1-DRV from >> Linux. >> I have checked the usb power at startup and i see the power goes on when >> in terminal report [sw-ehci1]: Set USB Power ON , but i dont know how it >> works. >> >> <6>hub 2-0:1.0: USB hub found >> [ 1.894384] hub 2-0:1.0: USB hub found >> <6>hub 2-0:1.0: 1 port detected >> [ 1.901073] hub 2-0:1.0: 1 port detected >> [sw-ehci2]: open clock >> [ 1.907602] [sw-ehci2]: open clock >> [sw-ehci2]: Set USB Power ON >> [ 1.923679] [sw-ehci2]: Set USB Power ON >> >> >> if any body has an idea please help. >> >> -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
/* * devmem2.c: Simple program to read/write from/to any location in memory. * * Copyright (C) 2000, Jan-Derk Bakker ([email protected]) * modified 2005 by Alessandro Rubini, to make it less verbose * * * This software has been developed for the LART computing board * (http://www.lart.tudelft.nl/). The development has been sponsored by * the Mobile MultiMedia Communications (http://www.mmc.tudelft.nl/) * and Ubiquitous Communications (http://www.ubicom.tudelft.nl/) * projects. * * The author can be reached at: * * Jan-Derk Bakker * Information and Communication Theory Group * Faculty of Information Technology and Systems * Delft University of Technology * P.O. Box 5031 * 2600 GA Delft * The Netherlands * * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <signal.h> #include <fcntl.h> #include <ctype.h> #include <termios.h> #include <sys/types.h> #include <sys/mman.h> #define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \ __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0) #define MAP_SIZE 4096UL #define MAP_MASK (MAP_SIZE - 1) int verbose = 0; int main(int argc, char **argv) { int fd; void *map_base, *virt_addr; unsigned long read_result, writeval; int wid; char format[16]; off_t target; int access_type = 'w'; setuid(0); /* try */ if(argc < 2) { fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n" "\taddress : memory address to act upon\n" "\ttype : access operation type : [b]yte, [h]alfword, [w]ord\n" "\tdata : data to be written\n\n", argv[0]); exit(1); } target = strtoul(argv[1], 0, 0); if(argc > 2) access_type = tolower(argv[2][0]); if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL; if (verbose) { printf("/dev/mem opened.\n"); fflush(stdout); } /* Map one page */ map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK); if(map_base == (void *) -1) FATAL; if (verbose) { printf("Memory mapped at address %p.\n", map_base); fflush(stdout); } virt_addr = map_base + (target & MAP_MASK); if (argc <= 3) { switch(access_type) { case 'b': read_result = *((unsigned char *) virt_addr); wid = 2; break; case 'h': read_result = *((unsigned short *) virt_addr); wid = 4; break; case 'w': read_result = *((unsigned long *) virt_addr); wid = 8; break; default: fprintf(stderr, "Illegal data type '%c'.\n", access_type); exit(2); } sprintf(format, "0x%%0%ix\n", wid); printf(format, read_result); fflush(stdout); } if(argc > 3) { writeval = strtoul(argv[3], 0, 0); switch(access_type) { case 'b': *((unsigned char *) virt_addr) = writeval; break; case 'h': *((unsigned short *) virt_addr) = writeval; break; case 'w': *((unsigned long *) virt_addr) = writeval; break; } } if(munmap(map_base, MAP_SIZE) == -1) FATAL; close(fd); return 0; }
