Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e3a07bba in mainline


Ignore:
Timestamp:
2013-12-31T22:31:21Z (8 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
ba4a03a5
Parents:
1bb9833
Message:

uhci: move legacy disabling to main

Location:
uspace/drv/bus/usb/uhci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/main.c

    r1bb9833 re3a07bba  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbuhcihc
     28/** @addtogroup drvusbuhci
    2929 * @{
    3030 */
     
    3535#include <assert.h>
    3636#include <ddf/driver.h>
     37#include <devman.h>
    3738#include <errno.h>
    3839#include <io/log.h>
     40#include <pci_dev_iface.h>
    3941#include <stdio.h>
    4042#include <str_error.h>
     
    5658};
    5759
     60/** Call the PCI driver with a request to clear legacy support register
     61 *
     62 * @param[in] device Device asking to disable interrupts
     63 * @return Error code.
     64 */
     65static int disable_legacy(ddf_dev_t *device)
     66{
     67        assert(device);
     68
     69        async_sess_t *parent_sess = devman_parent_device_connect(
     70            EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
     71        if (!parent_sess)
     72                return ENOMEM;
     73
     74        /* See UHCI design guide page 45 for these values.
     75         * Write all WC bits in USB legacy register */
     76        const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
     77
     78        async_hangup(parent_sess);
     79        return rc;
     80}
     81
    5882/** Initialize a new ddf driver instance for uhci hc and hub.
    5983 *
     
    6690        assert(device);
    6791
    68         const int ret = device_setup_uhci(device);
     92        int ret = disable_legacy(device);
     93        if (ret != EOK) {
     94                usb_log_error("Failed to disable legacy USB: %s.\n",
     95                    str_error(ret));
     96                return ret;
     97        }
     98
     99
     100        ret = device_setup_uhci(device);
    69101        if (ret != EOK) {
    70102                usb_log_error("Failed to initialize UHCI driver: %s.\n",
  • uspace/drv/bus/usb/uhci/uhci.c

    r1bb9833 re3a07bba  
    3838#include <ddf/interrupt.h>
    3939#include <device/hw_res_parsed.h>
    40 #include <pci_dev_iface.h>
    4140#include <devman.h>
    4241#include <errno.h>
     
    7574}
    7675
    77 /** Call the PCI driver with a request to clear legacy support register
    78  *
    79  * @param[in] device Device asking to disable interrupts
    80  * @return Error code.
    81  */
    82 static int disable_legacy(ddf_dev_t *device)
    83 {
    84         assert(device);
    85 
    86         async_sess_t *parent_sess = devman_parent_device_connect(
    87             EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    88         if (!parent_sess)
    89                 return ENOMEM;
    90 
    91         /* See UHCI design guide page 45 for these values.
    92          * Write all WC bits in USB legacy register */
    93         const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    94 
    95         async_hangup(parent_sess);
    96         return rc;
    97 }
    98 
    9976/** Initialize hc and rh DDF structures and their respective drivers.
    10077 *
     
    10380 * This function does all the preparatory work for hc and rh drivers:
    10481 *  - gets device's hw resources
    105  *  - disables UHCI legacy support (PCI config space)
    10682 *  - attempts to enable interrupts
    10783 *  - registers interrupt handler
     
    152128        }
    153129
    154         ret = disable_legacy(device);
    155         if (ret != EOK) {
    156                 usb_log_error("Failed to disable legacy USB: %s.\n",
    157                     str_error(ret));
    158                 goto irq_unregister;
    159         }
    160 
    161130        ret = hc_init(hc, &regs, interrupts);
    162131        if (ret != EOK) {
Note: See TracChangeset for help on using the changeset viewer.