|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% j. y# ^: ^2 l* A) Y* o8 }
#include <linux/init.h>
' x5 g6 w7 h( @" R#include <linux/module.h>
/ B3 K% n; d% k/ V) i6 n#include <linux/kernel.h>. {7 [1 ~0 r9 ~9 i k( L5 J4 P
#include <linux/types.h>" \4 M i( N* Z: y% Q, _* e# @
#include <linux/gpio.h>
$ q( z$ H; p2 d# V3 V9 O& Z4 y#include <linux/leds.h>
; W& ?2 X! S: \! `/ ^: X2 ]#include <linux/platform_device.h>9 W6 P; e( p9 z+ }
3 Q8 q$ _' y8 S1 e% h2 J' a0 K& q
#include <asm/mach-types.h>
: P9 P% @, t7 h2 k- V#include <asm/mach/arch.h>) G9 W$ m9 n, Z# @3 a. n3 M
#include <mach/da8xx.h>7 o- X- v$ O+ ~9 A
#include <mach/mux.h>
; p v6 a6 [9 q" F" _
" a! A7 J: t- n0 p6 y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 [# o4 u* |3 V } e/ s) a3 T7 k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 g6 D3 m+ K* ~4 U7 |8 k8 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 V1 n- d8 D2 ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 T" Q1 R# o9 x; ]
# ^" Y% F5 A6 P' |/* assign the tl som board LED-GPIOs*/
/ |* p# T ~. | D$ G& N# Zstatic const short da850_evm_tl_user_led_pins[] = {
/ F4 v) d7 X6 O5 g /* These pins are definition at <mach/mux.h> file */
! E$ u7 O, U) Y7 C# F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' c W6 i1 ~: o0 u) H -15 `1 h* A$ W/ Y5 O- l+ h' ?3 ?
};
4 |+ P! u8 M5 v6 F7 X
3 o0 Z2 d3 J( B- H2 P% Bstatic struct gpio_led da850_evm_tl_leds[] = {! e/ r7 b3 o" y' [
{% E) O" r0 o0 _7 c
.active_low = 0,+ z3 q6 Z7 s- C; U; S( |
.gpio = DA850_USER_LED0,1 f1 E9 n% i5 R& \- F+ Y+ f1 G6 i$ H+ }
.name = "user_led0",
2 J% \) H% Z1 F% |- | .default_trigger = "default-on",/ X2 Q/ W, M1 p2 J7 Y( w" ^
},. U( L7 l2 W% `( d
{. X0 F" q5 i5 o# P+ F) I& |- T! l
.active_low = 0,
' j. Y& v' v" r* I0 E# N .gpio = DA850_USER_LED1,3 X/ B* T" F4 T3 q% @8 ?( j
.name = "user_led1",
+ G% Z8 i, E' c4 R2 q .default_trigger = "default-on",
9 S' i% w1 r1 n) W$ D },5 K) ]1 M1 R, J+ i$ i2 H
{8 Z: |8 D5 p! k c' A& `- ^
.active_low = 0,# p- d$ Y- X$ i: \
.gpio = DA850_USER_LED2,- o: ^7 ^5 d; C; z" c) Q
.name = "user_led2",
6 e7 z) o$ G( B/ {! i, I; M .default_trigger = "default-on",
, q* M2 H O5 Z3 s },
; Z" y5 n# \( x. U {$ u# n' v" i+ x& G3 H7 G) B
.active_low = 0,
" o8 H* y8 l* a& q. c .gpio = DA850_USER_LED3,7 ~( n& w# x2 U: |- d! U; `' t
.name = "user_led3",
! X, V: S. T4 O( n6 {" d- } .default_trigger = "default-on",
, I- i" P% A) D9 C4 ]% Q$ F% w' f },% D- Z E9 ?) H+ D
};
- M& K" t' X+ D# ^0 d# \7 I+ W2 a6 Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 G! t! N* n2 a! E( O4 X. _' D8 V .leds = da850_evm_tl_leds,% s8 H+ u b+ g/ u7 J& c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. t- h; ?3 R @; B3 [ X: n ^) P
};( M8 X# W) N. B# c6 R8 P2 }
' F& ?8 V) z+ I) [( n3 a: r
static void led_dev_release(struct device *dev)6 s0 y- y# @, y( Z9 a% u( W' q2 `4 \6 p
{
' r7 ?" g! s3 X: ~& f7 F+ _};
}5 r6 U+ }2 I7 }& k
; T! Y3 f4 q+ z; ~* a, hstatic struct platform_device da850_evm_tl_leds_device = {
( Z+ N4 l, R4 @0 } b .name = "leds-gpio",8 ~: Z% V U4 |) a e& F7 A* T
.id = 1, ^5 A+ O( u% A; \! b
.dev = {4 S$ [+ u( g# m- ~- m
.platform_data = &da850_evm_tl_leds_pdata,7 B+ Y, S j1 O- ^8 S. g3 [8 V
.release = led_dev_release,1 v: k A4 n# N7 |: y5 z( b5 U
}
; F' C7 L8 r, W' S};# v- n2 t/ R5 n, ^% n. {7 w
8 F. K; Z9 C" t) z
static int __init led_platform_init(void)
9 A- ~: D& E X: F5 H+ G{; m H" ~: x; R. d
int ret;
3 p& ^3 F( P, u1 i( n, g4 z#if 0
" q3 w g7 H0 R w3 l# e! n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 ^1 Q$ Y0 \6 b& c& A) W- n if (ret)+ P+ x, p# A. n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ ` u5 C2 |( ~7 u "%d\n", ret);
7 \, W+ c4 ~8 Y% {#endif
; v8 \, H! P& H8 L5 x: h$ E ret = platform_device_register(&da850_evm_tl_leds_device);
% W o2 [: Q* l! v8 M if (ret)/ Q3 R2 ^) J7 h- v+ @1 `& l
pr_warning("Could not register som GPIO expander LEDS"); e9 Y8 D- G& {- Y4 M7 F7 j- y( H
else3 R' v7 ?4 n" A' P
printk(KERN_INFO "LED register sucessful!\n");
6 F, `7 X2 l0 g' [' n# v" b3 w4 m$ ~3 g
return ret;
, ]( ]. U5 y; O& _' V# U}
, i* N0 s3 R% s* o+ L1 m1 X: H! ~% t5 f# [! L9 u' b
static void __exit led_platform_exit(void)
: X9 W7 {3 v$ g6 W" u4 {{' N( E# U- q" q
platform_device_unregister(&da850_evm_tl_leds_device);) R4 C8 ~+ M9 C) z- u
/ T+ I& T0 [/ O* }2 I8 m5 h printk(KERN_INFO "LED unregister!\n");
- _4 c; [$ G \5 W4 Y}5 j$ {6 y) r7 `. U% j6 K) U3 R
+ b& i0 D7 L7 S+ K/ W4 Qmodule_init(led_platform_init);
% r5 m: G# c! B4 ~module_exit(led_platform_exit);8 C7 k @0 i( b# z
( a" ]2 y! I$ E4 \
MODULE_DESCRIPTION("Led platform driver");
6 {8 J9 _5 y( d, GMODULE_AUTHOR("Tronlong");: E7 J- d2 V% ~6 I$ d* B
MODULE_LICENSE("GPL");6 @' D, A8 R+ L
( _$ I2 W8 x* l" [( F$ x
|
|