|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) H3 }: A7 @( ]4 c#include <linux/init.h>
& z) _' t0 N: i/ F% q! z6 b7 e#include <linux/module.h>
4 J! K, q; {" m( l, y#include <linux/kernel.h>
' p X/ d) O# @$ R, s& Y8 @. X$ Y& l) |#include <linux/types.h>
8 h( r8 [9 K0 ~/ u: x#include <linux/gpio.h>- M1 ]6 ^6 L4 w- k# P3 r+ ^8 I
#include <linux/leds.h>
6 c9 y3 o. W8 T$ ?: K5 b#include <linux/platform_device.h>
* u$ W' H" k. H2 p6 \* C% l0 J4 f! Z( X: x# k5 P0 ^
#include <asm/mach-types.h>; f: D8 E% Q2 P
#include <asm/mach/arch.h>
! q8 D5 R' r6 @#include <mach/da8xx.h>
8 e# S( }$ R+ n6 S" j#include <mach/mux.h>
& F+ Y( p C( P. H4 }$ r# |! |' Q4 E/ T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& v% j( K6 R" I# Q0 ]$ _0 K( E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 q0 }/ D! a$ e0 c- h% A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 d: F. g0 k( |/ S1 F# x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) _/ N7 b) \# @* _& w/ f
+ U* @7 C2 h- P3 S
/* assign the tl som board LED-GPIOs*/
1 O% Z. K* @7 x; \5 Jstatic const short da850_evm_tl_user_led_pins[] = {9 B6 H* L9 R( N( p! q0 A' t i
/* These pins are definition at <mach/mux.h> file */
* A- F2 b ?" [8 _5 G+ ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; e8 S; V0 l* N5 l: f -1
( g+ }- o$ @- |1 F- i};2 S* ^3 B7 g4 L0 X6 M8 {# C4 U1 H% A
. l& x n( _) S# ]' r1 I
static struct gpio_led da850_evm_tl_leds[] = {6 _% q- L# s4 i0 s9 Y' C6 b
{ @! ?5 Z" F! B( _ i- [+ `
.active_low = 0,5 Q4 B! y& P. H& a% q) ?' T
.gpio = DA850_USER_LED0,
2 B+ E% k6 r, ~5 q .name = "user_led0",
1 W6 P6 e$ {+ a5 t6 e$ ^) L .default_trigger = "default-on",
- Q i- `$ ?6 `" u' B6 B( } },2 W. U3 R2 o3 `1 i+ ]
{
" B' p8 O# P* J: C .active_low = 0,! `, M' W' ^' {8 o
.gpio = DA850_USER_LED1,& @3 a7 u* s* D4 f
.name = "user_led1",: X0 d* t8 V7 h. m
.default_trigger = "default-on",
3 o3 z' ^, R: t: N+ ~ },
! V6 c8 x& F/ E: s {
, ]7 j2 { F1 b2 }' R .active_low = 0,
. f5 x e; I% S .gpio = DA850_USER_LED2,! k( p, T" Y2 q8 q/ e# @0 V
.name = "user_led2",; M$ d+ q0 w' V1 }8 j; f5 o
.default_trigger = "default-on",- W2 X0 |' x0 S0 y$ z2 n" r7 \8 k
},5 X+ t# A# M; O. D! d y* H
{
' T; P' P# k9 S! s .active_low = 0,
$ s V4 [, R* e- a" q0 ` .gpio = DA850_USER_LED3,. ]3 k2 A- ]9 j8 e3 x) `
.name = "user_led3",4 o# H" g* m" F: A0 {
.default_trigger = "default-on",, _$ J! I' U+ R4 |/ R. r
},
1 o; A% e. c7 Q};
' b- \5 o. A% F. q/ |, [0 j3 c
) b" s; A4 j f, W1 J {+ Q; i* {6 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ p- n' M* D! I/ `1 I7 r
.leds = da850_evm_tl_leds,) {/ l4 R$ l& L) U! c+ y+ `. y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( ?) I" R! ]# z. |! v5 Q0 Y};' v$ o) d7 T/ t* [
# S( D3 E0 V! k) F$ R: {
static void led_dev_release(struct device *dev)
/ }2 N6 h/ i+ j3 L+ b! P. M{
0 Q/ {) M* A9 w# r* i( U3 n};( M5 w) l/ `, \# d2 d- u0 i
4 c2 k5 E E) S1 t0 [
static struct platform_device da850_evm_tl_leds_device = {( ]$ G0 J8 V4 q" R4 @
.name = "leds-gpio",) s; y( {5 _0 r( Z: v* E$ s0 o
.id = 1,
. Z8 q& y# s0 Y1 m* A* l .dev = {0 @1 b9 \! S% p. N! [8 i3 j& @6 k
.platform_data = &da850_evm_tl_leds_pdata,
' ~) p0 C+ p: \% p .release = led_dev_release,- b2 Z% E& B* g
}) p7 l7 D2 l* v% s" D' N7 c. i
};
2 N3 |$ W4 N. x4 F4 ?8 N( w% [& Z
) ~9 \' ^- a* Qstatic int __init led_platform_init(void)
x4 l- N$ [8 B/ W W9 ]! v0 [7 P9 z{
8 i1 @1 D l1 Z- B Q/ j int ret;2 I; I4 J6 g) `
#if 0
* c [. F5 d# X5 c) i* E! t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ K1 m1 j" @2 m1 |7 Z if (ret)9 f4 D: |, ]* F9 n u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# {' K( ^0 V+ s- V; N "%d\n", ret);0 K3 @+ [3 _- a+ ~3 C4 H
#endif& y5 }. b, N0 w, F' ~
ret = platform_device_register(&da850_evm_tl_leds_device);, w! m+ ~* K3 K- A) b1 S7 [
if (ret)8 F% G; d7 @( V" ^) Q* z
pr_warning("Could not register som GPIO expander LEDS");+ H+ k f1 z/ n0 n
else
- O3 X4 `7 L5 W ~& l printk(KERN_INFO "LED register sucessful!\n");
7 U& J% p9 a2 D+ n( a
6 z" Z0 ]" u! e$ z" U3 @, a return ret;
- s0 ~+ o# s3 V3 F2 h* S5 B}
2 I% {+ j7 u: `) n5 r8 T/ p, V# h2 Y3 j
static void __exit led_platform_exit(void)
$ x/ m, V9 R2 m9 I{8 y! Q" A4 ?5 K$ m# X
platform_device_unregister(&da850_evm_tl_leds_device);
" D7 c4 U# l+ A1 ~/ F) s, m$ S- c/ [4 A6 I. g, N6 u' F
printk(KERN_INFO "LED unregister!\n");
9 f# u3 |/ c6 ^}
4 L3 V, C0 e/ o$ I, C# d6 `, ?$ V, F$ W( n
module_init(led_platform_init);
5 V9 N( A9 Y2 w; amodule_exit(led_platform_exit);- F& j+ L1 R; F9 Y: a4 P8 i
K2 r3 I; i9 eMODULE_DESCRIPTION("Led platform driver");0 _* U, a( X2 K
MODULE_AUTHOR("Tronlong");
' {/ o* p5 `3 p, F+ DMODULE_LICENSE("GPL");1 ~7 p, {* t0 y: k" P" |
& b' N5 l6 J* R5 n
|
|