1bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf/* 2bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * Copyright 2012 Tilera Corporation. All Rights Reserved. 3bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * 4bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * This program is free software; you can redistribute it and/or 5bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * modify it under the terms of the GNU General Public License 6bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * as published by the Free Software Foundation, version 2. 7bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * 8bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * This program is distributed in the hope that it will be useful, but 9bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * WITHOUT ANY WARRANTY; without even the implied warranty of 10bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 11bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * NON INFRINGEMENT. See the GNU General Public License for 12bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * more details. 13bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf */ 14bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 15bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf/* 16bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf * Implementation of trio gxio calls. 17bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf */ 18bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 19bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <linux/errno.h> 20bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <linux/io.h> 21bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <linux/module.h> 22bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 23bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <gxio/trio.h> 24bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <gxio/iorpc_globals.h> 25bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <gxio/iorpc_trio.h> 26bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf#include <gxio/kiorpc.h> 27bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 28bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalfint gxio_trio_init(gxio_trio_context_t *context, unsigned int trio_index) 29bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf{ 30bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf char file[32]; 31bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf int fd; 32bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 33bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf snprintf(file, sizeof(file), "trio/%d/iorpc", trio_index); 34bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf fd = hv_dev_open((HV_VirtAddr) file, 0); 35bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf if (fd < 0) { 36bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf context->fd = -1; 37bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 38bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX) 39bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf return fd; 40bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf else 41bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf return -ENODEV; 42bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf } 43bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 44bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf context->fd = fd; 45bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 46bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf return 0; 47bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf} 48bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris Metcalf 49bce5bbbb23f780a792be7e594af7cd4b4aae1cd4Chris MetcalfEXPORT_SYMBOL_GPL(gxio_trio_init); 50